Uploaded image for project: 'Nutch'
  1. Nutch
  2. NUTCH-3004

Avoid NPE in HttpResponse

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Fixed
    • 1.19
    • 1.20
    • plugin, protocol
    • None

    Description

      I recently deployed nutch on a FIPS enabled rhel 8 instance, and I got an NPE in HttpResponse. When I set the log level to debug, I could see what was happening, but it would have been better to get a meaningful exception rather than an NPE.

      The issue is that in the catch clause, the exception is propagated only if the message is "handshake alert..." and then the reconnect fails. If the message is not that, then the ssl socket remains null, and we get an NPE below the source I quote here.

      I think we should throw the same HTTPException that we do throw in the nested try if the message is not "handshake alert..."

              try {
                sslsocket = getSSLSocket(socket, sockHost, sockPort);
                sslsocket.startHandshake();
              } catch (Exception e) {
                Http.LOG.debug("SSL connection to {} failed with: {}", url,
                    e.getMessage());
                if ("handshake alert:  unrecognized_name".equals(e.getMessage())) {
                  try {
                    // Reconnect, see NUTCH-2447
                    socket = new Socket();
                    socket.setSoTimeout(http.getTimeout());
                    socket.connect(sockAddr, http.getTimeout());
                    sslsocket = getSSLSocket(socket, "", sockPort);
                    sslsocket.startHandshake();
                  } catch (Exception ex) {
                    String msg = "SSL reconnect to " + url + " failed with: "
                        + e.getMessage();
                    throw new HttpException(msg);
                  }
                }
              }
              socket = sslsocket;
            }
      
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              tallison Tim Allison
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: