{"record":{"id":"d9a8257367500c81","repo":"apache/hadoop","slug":"caught-interrupted","errorCode":null,"errorMessage":"caught interrupted","messagePattern":"caught interrupted","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java","lineNumber":780,"sourceCode":"      return token;\n    }\n  }\n\n  /**\n   * Renew a delegation token\n   * @param token the token to renew\n   * @return the new expiration time\n   * @throws IOException\n   * @deprecated Use Token.renew instead.\n   */\n  @Deprecated\n  public long renewDelegationToken(Token<DelegationTokenIdentifier> token)\n      throws IOException {\n    LOG.info(\"Renewing {}\", DelegationTokenIdentifier.stringifyToken(token));\n    try {\n      return token.renew(conf);\n    } catch (InterruptedException ie) {\n      throw new RuntimeException(\"caught interrupted\", ie);\n    } catch (RemoteException re) {\n      throw re.unwrapRemoteException(InvalidToken.class,\n          AccessControlException.class);\n    }\n  }\n\n  /**\n   * Cancel a delegation token\n   * @param token the token to cancel\n   * @throws IOException\n   * @deprecated Use Token.cancel instead.\n   */\n  @Deprecated\n  public void cancelDelegationToken(Token<DelegationTokenIdentifier> token)\n      throws IOException {\n    LOG.info(\"Cancelling {}\", DelegationTokenIdentifier.stringifyToken(token));\n    try {\n      token.cancel(conf);","sourceCodeStart":762,"sourceCodeEnd":798,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/DFSClient.java#L762-L798","documentation":"The deprecated DFSClient.renewDelegationToken() renews a delegation token; renewal executes through UserGroupInformation.doAs, which can throw InterruptedException (e.g. during relogin). The deprecated wrapper flattens that into a bare RuntimeException('caught interrupted'), discarding the typed contract and the thread's interrupt status.","triggerScenarios":"Invoking the deprecated renewDelegationToken(token) from a thread that is already interrupted or gets interrupted mid-RPC: executor shutdownNow(), MR/Spark task cancellation, or a concurrent kerberos relogin inside doAs.","commonSituations":"Legacy MR job-token renewal code paths on older client versions; token-renewal daemons sharing threads with cancellable work; tests that interrupt worker pools while renewal is in flight.","solutions":["Migrate to the supported API: token.renew(conf) (Token.renew), which declares InterruptedException so you can handle it properly.","If the old API must stay, catch RuntimeException, test re.getCause() instanceof InterruptedException, restore the interrupt flag with Thread.currentThread().interrupt(), and decide to abort or reschedule renewal.","Run renewal on a dedicated scheduler thread that is never cancelled with shutdownNow() mid-RPC."],"exampleFix":"// before\nclient.renewDelegationToken(token);\n// RuntimeException: caught interrupted\n\n// after\ntry {\n  long nextExpiry = token.renew(conf);\n} catch (InterruptedException ie) {\n  Thread.currentThread().interrupt();\n  // abort this renewal attempt or reschedule it\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  client.renewDelegationToken(token);\n} catch (RuntimeException re) {\n  if (re.getCause() instanceof InterruptedException) {\n    Thread.currentThread().interrupt(); // preserve the interrupt, abort or reschedule\n  } else { throw re; }\n}","preventionTips":["Prefer Token.renew(conf) over the deprecated DFSClient wrapper.","Run token renewal in a dedicated thread you never shutdownNow() mid-RPC.","Always restore the interrupt flag when handling interruption-derived errors."],"tags":["hdfs","delegation-token","thread-interruption","deprecated-api","kerberos"],"backgroundTag":"thread-interrupted","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}