test_class.file: http/src/test/java/ro/polak/http/ServerRunnableTest.java
test_class.identifier: ServerRunnableTest
test_case.body: @Test
      public void shouldLogIOExceptionsSilently() throws Exception {
  
          Socket socket = mock(Socket.class);
          HttpServletResponseImplFactory responseFactory = mock(HttpServletResponseImplFactory.class);
  
          when(responseFactory.createFromSocket(socket)).thenThrow(new IOException());
  
          ServerRunnable serverRunnable = new ServerRunnable(socket, mock(ServerConfig.class),
                  mock(HttpServletRequestImplFactory.class),
                  responseFactory,
                  mock(HttpErrorHandlerResolver.class),
                  new PathHelper()
          );
  
          serverRunnable.run();
  
          verify(socket, times(1)).close();
      }
test_case.class_method_signature: ServerRunnableTest.shouldLogIOExceptionsSilently()
test_case.full_signature: @Test public void shouldLogIOExceptionsSilently()
test_case.identifier: shouldLogIOExceptionsSilently
test_case.invocations: mock mock thenThrow when createFromSocket mock mock mock run close verify times
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldLogIOExceptionsSilently()
focal_class.declarator: LOGGER = Logger.getLogger(ServerRunnable.class.getName())
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = Logger.getLogger(ServerRunnable.class.getName());
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: serverConfig
focal_class.modifier: private final
focal_class.original_string: private final ServerConfig serverConfig;
focal_class.type: ServerConfig
focal_class.var_name: serverConfig
focal_class.declarator: socket
focal_class.modifier: private final
focal_class.original_string: private final Socket socket;
focal_class.type: Socket
focal_class.var_name: socket
focal_class.declarator: requestFactory
focal_class.modifier: private final
focal_class.original_string: private final HttpServletRequestImplFactory requestFactory;
focal_class.type: HttpServletRequestImplFactory
focal_class.var_name: requestFactory
focal_class.declarator: responseFactory
focal_class.modifier: private final
focal_class.original_string: private final HttpServletResponseImplFactory responseFactory;
focal_class.type: HttpServletResponseImplFactory
focal_class.var_name: responseFactory
focal_class.declarator: httpErrorHandlerResolver
focal_class.modifier: private final
focal_class.original_string: private final HttpErrorHandlerResolver httpErrorHandlerResolver;
focal_class.type: HttpErrorHandlerResolver
focal_class.var_name: httpErrorHandlerResolver
focal_class.declarator: pathHelper
focal_class.modifier: private final
focal_class.original_string: private final PathHelper pathHelper;
focal_class.type: PathHelper
focal_class.var_name: pathHelper
focal_class.file: http/src/main/java/ro/polak/http/ServerRunnable.java
focal_class.identifier: ServerRunnable
focal_class.interfaces: implements Runnable
focal_class.class_method_signature: ServerRunnable.ServerRunnable(final Socket socket,
                            final ServerConfig serverConfig,
                            final HttpServletRequestImplFactory requestFactory,
                            final HttpServletResponseImplFactory responseFactory,
                            final HttpErrorHandlerResolver httpErrorHandlerResolver,
                            final PathHelper pathHelper)
focal_class.full_signature: public  ServerRunnable(final Socket socket,
                            final ServerConfig serverConfig,
                            final HttpServletRequestImplFactory requestFactory,
                            final HttpServletResponseImplFactory responseFactory,
                            final HttpErrorHandlerResolver httpErrorHandlerResolver,
                            final PathHelper pathHelper)
focal_class.identifier: ServerRunnable
focal_class.modifiers: public
focal_class.parameters: (final Socket socket,
                            final ServerConfig serverConfig,
                            final HttpServletRequestImplFactory requestFactory,
                            final HttpServletResponseImplFactory responseFactory,
                            final HttpErrorHandlerResolver httpErrorHandlerResolver,
                            final PathHelper pathHelper)
focal_class.signature:  ServerRunnable(final Socket socket,
                            final ServerConfig serverConfig,
                            final HttpServletRequestImplFactory requestFactory,
                            final HttpServletResponseImplFactory responseFactory,
                            final HttpErrorHandlerResolver httpErrorHandlerResolver,
                            final PathHelper pathHelper)
focal_class.class_method_signature: ServerRunnable.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_class.class_method_signature: ServerRunnable.setDefaultResponseHeaders(final HttpServletRequest request, final HttpServletResponseImpl response)
focal_class.full_signature: private void setDefaultResponseHeaders(final HttpServletRequest request, final HttpServletResponseImpl response)
focal_class.identifier: setDefaultResponseHeaders
focal_class.modifiers: private
focal_class.parameters: (final HttpServletRequest request, final HttpServletResponseImpl response)
focal_class.return: void
focal_class.signature: void setDefaultResponseHeaders(final HttpServletRequest request, final HttpServletResponseImpl response)
focal_class.class_method_signature: ServerRunnable.validateRequest(final HttpServletRequest request)
focal_class.full_signature: private void validateRequest(final HttpServletRequest request)
focal_class.identifier: validateRequest
focal_class.modifiers: private
focal_class.parameters: (final HttpServletRequest request)
focal_class.return: void
focal_class.signature: void validateRequest(final HttpServletRequest request)
focal_class.class_method_signature: ServerRunnable.isMethodSupported(final String method)
focal_class.full_signature: private boolean isMethodSupported(final String method)
focal_class.identifier: isMethodSupported
focal_class.modifiers: private
focal_class.parameters: (final String method)
focal_class.return: boolean
focal_class.signature: boolean isMethodSupported(final String method)
focal_class.class_method_signature: ServerRunnable.getSocket()
focal_class.full_signature: protected Socket getSocket()
focal_class.identifier: getSocket
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: Socket
focal_class.signature: Socket getSocket()
focal_method.body: @Override
      public void run() {
          HttpServletResponseImpl response = null;
  
          try {
              try {
                  response = responseFactory.createFromSocket(socket);
                  HttpServletRequestImpl request = requestFactory.createFromSocket(socket);
  
                  LOGGER.log(Level.INFO, "Handling request {0} {1}", new Object[]{
                          request.getMethod(), request.getRequestURI()
                  });
  
                  String requestedPath = request.getRequestURI();
  
                  if (pathHelper.isPathContainingIllegalCharacters(requestedPath)) {
                      throw new AccessDeniedException();
                  }
  
                  validateRequest(request);
                  setDefaultResponseHeaders(request, response);
                  serverConfig.getServletDispatcher().load(requestedPath, request, response);
              } catch (RuntimeException e) {
                  if (response != null) {
                      httpErrorHandlerResolver.getHandler(e).serve(response);
                  }
  
                  throw e; // Make it logged by the main thread
              } finally {
                  IOUtilities.closeSilently(socket);
              }
          } catch (IOException e) {
              LOGGER.log(Level.INFO, "Encountered IOException when handling request {0}", new Object[]{
                      e.getMessage()
              });
          }
      }
focal_method.class_method_signature: ServerRunnable.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: createFromSocket createFromSocket log getMethod getRequestURI getRequestURI isPathContainingIllegalCharacters validateRequest setDefaultResponseHeaders load getServletDispatcher serve getHandler closeSilently log getMessage
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()