Skip to content

Commit ec71c10

Browse files
committed
Fix NPE caused by SLI logging introductions in ProxyAcceptHandler
1 parent 8805f15 commit ec71c10

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

addons/httprox/common/src/main/java/org/commonjava/indy/httprox/handler/ProxyAcceptHandler.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,24 +143,24 @@ public void handleEvent( AcceptingChannel<StreamConnection> channel )
143143
try
144144
{
145145
accepted = channel.accept();
146-
147-
MDC.put( REQUEST_PHASE, REQUEST_PHASE_START );
148-
LoggerFactory.getLogger( PROXY_METRIC_LOGGER )
149-
.info( "START HTTProx request (from: {})", accepted.getPeerAddress() );
150-
MDC.remove( REQUEST_PHASE );
151-
152146
}
153147
catch ( IOException e )
154148
{
155-
logger.error( "Failed to addMetadata httprox connection: " + e.getMessage(), e );
156-
return;
149+
logger.error( "Failed to accept httprox connection: " + e.getMessage(), e );
150+
accepted = null;
157151
}
158152

153+
// to remove the return in the catch clause, which is bad form...
159154
if ( accepted == null )
160155
{
161156
return;
162157
}
163158

159+
MDC.put( REQUEST_PHASE, REQUEST_PHASE_START );
160+
LoggerFactory.getLogger( PROXY_METRIC_LOGGER )
161+
.info( "START HTTProx request (from: {})", accepted.getPeerAddress() );
162+
MDC.remove( REQUEST_PHASE );
163+
164164
logger.debug( "accepted {}", accepted.getPeerAddress() );
165165

166166
final ConduitStreamSourceChannel source = accepted.getSourceChannel();

0 commit comments

Comments
 (0)