forked from woggioni/rbcs
improved error handling
This commit is contained in:
@@ -149,7 +149,10 @@ class RemoteBuildCacheServer(private val cfg: Configuration) {
|
|||||||
((user?.groups ?: emptySet()).asSequence() + sequenceOf(group).filterNotNull()).toSet()
|
((user?.groups ?: emptySet()).asSequence() + sequenceOf(group).filterNotNull()).toSet()
|
||||||
AuthenticationResult(user, allGroups)
|
AuthenticationResult(user, allGroups)
|
||||||
} ?: anonymousUserGroups?.let { AuthenticationResult(null, it) }
|
} ?: anonymousUserGroups?.let { AuthenticationResult(null, it) }
|
||||||
} catch (es: SSLPeerUnverifiedException) {
|
} catch (ex: SSLPeerUnverifiedException) {
|
||||||
|
log.debug(ctx) {
|
||||||
|
ex.message ?: "Error witch client certificate authentication"
|
||||||
|
}
|
||||||
anonymousUserGroups?.let { AuthenticationResult(null, it) }
|
anonymousUserGroups?.let { AuthenticationResult(null, it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import net.woggioni.rbcs.api.exception.ContentTooLargeException
|
|||||||
import net.woggioni.rbcs.common.contextLogger
|
import net.woggioni.rbcs.common.contextLogger
|
||||||
import net.woggioni.rbcs.common.debug
|
import net.woggioni.rbcs.common.debug
|
||||||
import net.woggioni.rbcs.common.log
|
import net.woggioni.rbcs.common.log
|
||||||
|
import net.woggioni.rbcs.server.RemoteBuildCacheServer
|
||||||
import org.slf4j.event.Level
|
import org.slf4j.event.Level
|
||||||
import org.slf4j.spi.LoggingEventBuilder
|
import org.slf4j.spi.LoggingEventBuilder
|
||||||
|
|
||||||
@@ -59,27 +60,38 @@ object ExceptionHandler : ChannelDuplexHandler() {
|
|||||||
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
|
override fun exceptionCaught(ctx: ChannelHandlerContext, cause: Throwable) {
|
||||||
when (cause) {
|
when (cause) {
|
||||||
is DecoderException -> {
|
is DecoderException -> {
|
||||||
log.debug(cause.message, cause)
|
if(log.isDebugEnabled) {
|
||||||
|
log.debug(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.close()
|
ctx.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
is ConnectException -> {
|
is ConnectException -> {
|
||||||
log.error(cause.message, cause)
|
if(log.isErrorEnabled) {
|
||||||
|
log.error(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.writeAndFlush(SERVER_ERROR.retainedDuplicate())
|
ctx.writeAndFlush(SERVER_ERROR.retainedDuplicate())
|
||||||
}
|
}
|
||||||
|
|
||||||
is SocketException -> {
|
is SocketException -> {
|
||||||
log.debug(cause.message, cause)
|
if(log.isDebugEnabled) {
|
||||||
|
log.debug(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.close()
|
ctx.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
is SSLPeerUnverifiedException -> {
|
is SSLPeerUnverifiedException -> {
|
||||||
|
if(log.isDebugEnabled) {
|
||||||
|
log.debug(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.writeAndFlush(NOT_AUTHORIZED.retainedDuplicate())
|
ctx.writeAndFlush(NOT_AUTHORIZED.retainedDuplicate())
|
||||||
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE)
|
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE)
|
||||||
}
|
}
|
||||||
|
|
||||||
is SSLException -> {
|
is SSLException -> {
|
||||||
log.debug(cause.message, cause)
|
if(log.isDebugEnabled) {
|
||||||
|
log.debug(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.close()
|
ctx.close()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,13 +120,17 @@ object ExceptionHandler : ChannelDuplexHandler() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
is CacheException -> {
|
is CacheException -> {
|
||||||
log.error(cause.message, cause)
|
if(log.isErrorEnabled) {
|
||||||
|
log.error(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.writeAndFlush(NOT_AVAILABLE.retainedDuplicate())
|
ctx.writeAndFlush(NOT_AVAILABLE.retainedDuplicate())
|
||||||
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE)
|
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE)
|
||||||
}
|
}
|
||||||
|
|
||||||
else -> {
|
else -> {
|
||||||
log.error(cause.message, cause)
|
if(log.isErrorEnabled) {
|
||||||
|
log.error(cause.message, cause)
|
||||||
|
}
|
||||||
ctx.writeAndFlush(SERVER_ERROR.retainedDuplicate())
|
ctx.writeAndFlush(SERVER_ERROR.retainedDuplicate())
|
||||||
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE)
|
.addListener(ChannelFutureListener.CLOSE_ON_FAILURE)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user