Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix detekt's SwallowedException warnings #237

Merged
merged 2 commits into from
May 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ compileKotlin.kotlinOptions {
}

detekt {
baseline = file("$projectDir/detekt/baseline.xml")
config = files("$projectDir/detekt/config.yml")
buildUponDefaultConfig = true
}
8 changes: 0 additions & 8 deletions detekt/baseline.xml

This file was deleted.

3 changes: 3 additions & 0 deletions src/main/kotlin/io/libp2p/core/multiformats/MultiaddrDns.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.libp2p.core.multiformats

import org.apache.logging.log4j.LogManager
import java.net.Inet4Address
import java.net.Inet6Address
import java.net.InetAddress
Expand All @@ -12,6 +13,7 @@ class MultiaddrDns {
}

companion object {
private val log = LogManager.getLogger(MultiaddrDns::class.java)
private val dnsProtocols = arrayOf(Protocol.DNS4, Protocol.DNS6, Protocol.DNSADDR)

fun resolve(addr: Multiaddr, resolver: Resolver = DefaultResolver): List<Multiaddr> {
Expand Down Expand Up @@ -52,6 +54,7 @@ class MultiaddrDns {
}
}
} catch (e: UnknownHostException) {
log.debug(e)
return emptyList()
// squash, as this might not be fatal,
// and if it is we'll handle this higher up the call chain
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/io/libp2p/etc/types/AsyncExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fun <C> CompletableFuture<C>.forward(forwardTo: CompletableFuture<in C>) = forwa
/**
* The same as [CompletableFuture.get] but unwraps [ExecutionException]
*/
@Suppress("SwallowedException")
fun <C> CompletableFuture<C>.getX(): C {
try {
return get()
Expand All @@ -36,6 +37,7 @@ fun <C> CompletableFuture<C>.getX(): C {
/**
* The same as [CompletableFuture.get] but unwraps [ExecutionException]
*/
@Suppress("SwallowedException")
fun <C> CompletableFuture<C>.getX(timeoutSec: Double): C {
try {
return get((timeoutSec * 1000).toLong(), TimeUnit.MILLISECONDS)
Expand Down