http 500->400 for expected errors

This commit is contained in:
Arndt Brenschede 2020-02-09 18:55:29 +01:00
parent 42486f73f1
commit 47e20c681f

View file

@ -230,7 +230,7 @@ public class RouteServer extends Thread implements Comparable<RouteServer>
if ( cr.getErrorMessage() != null ) if ( cr.getErrorMessage() != null )
{ {
writeHttpHeader(bw, HTTP_STATUS_INTERNAL_SERVER_ERROR); writeHttpHeader(bw, HTTP_STATUS_BAD_REQUEST);
bw.write( cr.getErrorMessage() ); bw.write( cr.getErrorMessage() );
bw.write( "\n" ); bw.write( "\n" );
} }
@ -331,10 +331,9 @@ public class RouteServer extends Thread implements Comparable<RouteServer>
server.starttime = System.currentTimeMillis(); server.starttime = System.currentTimeMillis();
// kill an old thread if thread limit reached // kill an old thread if thread limit reached
cleanupThreadQueue( threadQueue ); cleanupThreadQueue( threadQueue );
if ( debug ) System.out.println( "threadQueue.size()=" + threadQueue.size() ); if ( debug ) System.out.println( "threadQueue.size()=" + threadQueue.size() );
if ( threadQueue.size() >= maxthreads ) if ( threadQueue.size() >= maxthreads )
{ {
@ -345,6 +344,13 @@ public class RouteServer extends Thread implements Comparable<RouteServer>
long maxage = server.starttime - threadQueue.peek().starttime; long maxage = server.starttime - threadQueue.peek().starttime;
long maxWaitTime = 2000L-maxage; long maxWaitTime = 2000L-maxage;
if ( debug ) System.out.println( "maxage=" + maxage + " maxWaitTime=" + maxWaitTime ); if ( debug ) System.out.println( "maxage=" + maxage + " maxWaitTime=" + maxWaitTime );
if ( debug )
{
for ( RouteServer t : threadQueue )
{
System.out.println( "age=" + (server.starttime - t.starttime) );
}
}
if ( maxWaitTime > 0 ) if ( maxWaitTime > 0 )
{ {
threadPoolSync.wait( maxWaitTime ); threadPoolSync.wait( maxWaitTime );