{"record":{"id":"76ce43c3b0ef426d","repo":"android-async-http/android-async-http","slug":"http-response-may-not-be-null","errorCode":null,"errorMessage":"HTTP response may not be null","messagePattern":"HTTP response may not be null","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"library/src/main/java/com/loopj/android/http/MyRedirectHandler.java","lineNumber":63,"sourceCode":"class MyRedirectHandler extends DefaultRedirectHandler {\n\n    private static final String REDIRECT_LOCATIONS = \"http.protocol.redirect-locations\";\n    private final boolean enableRedirects;\n\n    public MyRedirectHandler(final boolean allowRedirects) {\n        super();\n        this.enableRedirects = allowRedirects;\n    }\n\n    @Override\n    public boolean isRedirectRequested(\n            final HttpResponse response,\n            final HttpContext context) {\n        if (!enableRedirects) {\n            return false;\n        }\n        if (response == null) {\n            throw new IllegalArgumentException(\"HTTP response may not be null\");\n        }\n        int statusCode = response.getStatusLine().getStatusCode();\n        switch (statusCode) {\n            case HttpStatus.SC_MOVED_TEMPORARILY:\n            case HttpStatus.SC_MOVED_PERMANENTLY:\n            case HttpStatus.SC_SEE_OTHER:\n            case HttpStatus.SC_TEMPORARY_REDIRECT:\n                return true;\n            default:\n                return false;\n        } //end of switch\n    }\n\n    @Override\n    public URI getLocationURI(\n            final HttpResponse response,\n            final HttpContext context) throws ProtocolException {\n        if (response == null) {","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/android-async-http/android-async-http/blob/018a0b8d96a0dd569de9f8128cfe5d030e0423ef/library/src/main/java/com/loopj/android/http/MyRedirectHandler.java#L45-L81","documentation":"A null-guard inside MyRedirectHandler.isRedirectRequested, copied from DefaultRedirectHandler's contract. The redirect handler is invoked with the current HttpResponse; a null response means the redirect policy is being consulted outside a valid response context (internal client misuse). Note it is only reachable when enableRedirects is true.","triggerScenarios":"Thrown at library/src/main/java/com/loopj/android/http/MyRedirectHandler.java:63 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the redirect handler is only used with a properly configured HttpClient that always passes a real HttpResponse","Do not call isRedirectRequested manually; let the client's redirect strategy invoke it","Wrap request execution so failures surface as client errors rather than reaching the redirect stage with no response"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"018a0b8d96a0dd569de9f8128cfe5d030e0423ef","analyzedAt":"2026-09-09T15:22:01.829Z","contentChangedAt":"2026-09-09T15:22:01.829Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}