{"record":{"id":"44d7b6fab7fb8eb8","repo":"apache/hadoop","slug":"invalid-operation","errorCode":null,"errorMessage":"Invalid operation.","messagePattern":"Invalid operation\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Schedulable.java","lineNumber":43,"sourceCode":" * Interface which allows extracting information necessary to\n * create schedulable identity strings.\n */\n@InterfaceAudience.Private\npublic interface Schedulable {\n  public UserGroupInformation getUserGroupInformation();\n\n  /**\n   * This is overridden only in {@link Server.Call}.\n   * The CallerContext field will be used to carry information\n   * about the user in cases where UGI proves insufficient.\n   * Any other classes that might try to use this method,\n   * will get an UnsupportedOperationException.\n   *\n   * @return an instance of CallerContext if method\n   * is overridden else get an UnsupportedOperationException\n   */\n  default CallerContext getCallerContext() {\n    throw new UnsupportedOperationException(\"Invalid operation.\");\n  }\n\n  int getPriorityLevel();\n}\n","sourceCodeStart":25,"sourceCodeEnd":48,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/ipc/Schedulable.java#L25-L48","documentation":"Schedulable.getCallerContext is a default method whose only implementation is on Server.Call; every other Schedulable gets UnsupportedOperationException(\"Invalid operation.\") by design. The method exists so call-queue code can read caller context only from real RPC calls — the class javadoc on the method says exactly this.","triggerScenarios":"Calling schedulable.getCallerContext() on anything that is not a Server.Call: unit-test fakes implementing Schedulable, custom call-queue entries or wrappers that implement Schedulable without extending Server.Call, generic metrics code assuming all schedulables carry context.","commonSituations":"Custom CallQueue/backpressure implementations inspecting queued entries; tests passing fake Schedulables into scheduler or metrics code that reads caller context; refactors that route Server.Call through adapter objects.","solutions":["Narrow before calling: only invoke getCallerContext() when the schedulable instanceof Server.Call.","If your Schedulable wrapper genuinely carries context, override getCallerContext() in your implementation.","Audit generic code paths so caller context is only requested for real calls."],"exampleFix":"// before\nCallerContext ctx = schedulable.getCallerContext(); // UnsupportedOperationException on non-Call\n// after\nCallerContext ctx = (schedulable instanceof Server.Call)\n    ? schedulable.getCallerContext()\n    : null;","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"static boolean carriesCallerContext(Schedulable s) {\n  return s instanceof org.apache.hadoop.ipc.Server.Call;\n}","tryCatchPattern":null,"preventionTips":["Treat getCallerContext as Server.Call-only API — check instanceof before calling.","Override getCallerContext in custom Schedulables that flow through code reading caller context.","In tests, pass real Server.Call instances (or stubs extending it) when context is read."],"tags":["rpc","schedulable","call-queue","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}