{"record":{"id":"149c86d1bad8a0c5","repo":"TooTallNate/Java-WebSocket","slug":"http-resource-descriptor-must-not-be-null","errorCode":null,"errorMessage":"http resource descriptor must not be null","messagePattern":"http resource descriptor must not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"src/main/java/org/java_websocket/handshake/HandshakeImpl1Client.java","lineNumber":41,"sourceCode":" *  OTHER DEALINGS IN THE SOFTWARE.\n */\n\npackage org.java_websocket.handshake;\n\n/**\n * Implementation for a client handshake\n */\npublic class HandshakeImpl1Client extends HandshakedataImpl1 implements ClientHandshakeBuilder {\n\n  /**\n   * Attribute for the resource descriptor\n   */\n  private String resourceDescriptor = \"*\";\n\n  @Override\n  public void setResourceDescriptor(String resourceDescriptor) {\n    if (resourceDescriptor == null) {\n      throw new IllegalArgumentException(\"http resource descriptor must not be null\");\n    }\n    this.resourceDescriptor = resourceDescriptor;\n  }\n\n  @Override\n  public String getResourceDescriptor() {\n    return resourceDescriptor;\n  }\n}\n","sourceCodeStart":23,"sourceCodeEnd":51,"githubUrl":"https://github.com/TooTallNate/Java-WebSocket/blob/afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d/src/main/java/org/java_websocket/handshake/HandshakeImpl1Client.java#L23-L51","documentation":"HandshakeImpl1Client.setResourceDescriptor() throws IllegalArgumentException when handed a null resource descriptor. The resource descriptor is the HTTP request path (e.g. \"/path?query\") of the handshake and must always be a non-null string; the field defaults to \"*\".","triggerScenarios":"Calling setResourceDescriptor(null) directly, or via translateHandshakeHttpServer when the incoming HTTP request has no usable path/URI (e.g. a malformed request line).","commonSituations":"Custom handshake translation code, HTTP clients issuing requests without a path, or proxies stripping the request URI.","solutions":["Never pass null; default to \"/\" when the path is missing","Before calling, check the request's path/URI for null and substitute a sensible default","If triggered inside translateHandshakeHttpServer, validate the raw HTTP request line before translating the handshake"],"exampleFix":"// before\nhandshake.setResourceDescriptor(request.getPath()); // may be null\n// after\nString path = request.getPath();\nhandshake.setResourceDescriptor(path != null ? path : \"/\");","handlingStrategy":"type-guard","validationCode":"if (path == null || path.isEmpty()) { path = \"/\"; }","typeGuard":"String safeDescriptor(String path) {\n  return (path == null || path.isEmpty()) ? \"/\" : path;\n}","tryCatchPattern":"try {\n  handshake.setResourceDescriptor(path);\n} catch (IllegalArgumentException e) {\n  handshake.setResourceDescriptor(\"/\");\n}","preventionTips":["Default missing request paths to \"/\" in handshake translation code","Validate the HTTP request line before building the handshake","Never propagate raw nullable header/URI values into setters"],"tags":["websocket","handshake","null-argument"],"backgroundTag":"null-argument","analyzedSha":"afeacbf8c0f6f6a761c9d9daed8c813dd3b8ed7d","analyzedAt":"2026-09-09T14:39:47.546Z","contentChangedAt":"2026-09-09T14:39:47.546Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}