{"record":{"id":"f64ba0ba3ef25005","repo":"eclipse-vertx/vert.x","slug":"unsupportedoperationexception","errorCode":null,"errorMessage":"UnsupportedOperationException","messagePattern":"UnsupportedOperationException","errorType":"exception","errorClass":"java.lang.UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"vertx-core/src/main/java/io/vertx/core/http/impl/headers/Http1xHeaders.java","lineNumber":481,"sourceCode":"      if (ref != null) {\n        entries = null;\n      } else if (entries != null) {\n        Arrays.fill(entries, null);\n      }\n    }\n  }\n\n  public String toString() {\n    StringBuilder sb = new StringBuilder();\n    for (Map.Entry<String, String> entry: this) {\n      sb.append(entry).append('\\n');\n    }\n    return sb.toString();\n  }\n\n  @Override\n  public Integer getInt(CharSequence name) {\n    throw new UnsupportedOperationException();\n  }\n\n  @Override\n  public int getInt(CharSequence name, int defaultValue) {\n    String value = get(name);\n    if (value == null) {\n      return defaultValue;\n    }\n    try {\n      return Integer.parseInt(value);\n    } catch (NumberFormatException e) {\n      return defaultValue;\n    }\n  }\n\n  @Override\n  public Short getShort(CharSequence name) {\n    throw new UnsupportedOperationException();","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/eclipse-vertx/vert.x/blob/fb308bd8c3f12c79f4ae89bef67fadf6c80d036e/vertx-core/src/main/java/io/vertx/core/http/impl/headers/Http1xHeaders.java#L463-L499","documentation":"Http1xHeaders does not support numeric conversions: getInt(CharSequence name) unconditionally throws UnsupportedOperationException. HTTP/1.x headers are stored as strings and this Vert.x implementation deliberately omits integer parsing helpers.","triggerScenarios":"Any direct call to http1xHeaders.getInt(name) — e.g. calling a generic HttpHeaders API that assumes numeric accessors exist, or casting a MultiMap to HttpHeaders and calling getInt.","commonSituations":"Reading numeric headers like Content-Length or custom IDs assuming netty-style helper methods work; code migrated from Netty's HttpHeaders API; generic header-processing utilities that probe numeric getters.","solutions":["Use getString/get(name) and parse with Integer.parseInt yourself (with NumberFormatException handling)","Use getInt(CharSequence, int defaultValue) which is implemented and parses via get()","Route numeric parsing through a shared utility for null-safety","Do not call unsupported accessors on Http1xHeaders; target the string-based API"],"exampleFix":"// before\nInteger len = headers.getInt(\"Content-Length\"); // UnsupportedOperationException\n// after\nString v = headers.get(\"Content-Length\");\nInteger len = v == null ? null : Integer.parseInt(v.trim());","handlingStrategy":"type-guard","validationCode":"String v = headers.get(\"Content-Length\");\nInteger len = (v != null && v.matches(\"\\\\d+\")) ? Integer.valueOf(v) : null;","typeGuard":"static Integer safeGetInt(MultiMap headers, CharSequence name) {\n  String v = headers.get(name);\n  if (v == null) return null;\n  try { return Integer.parseInt(v.trim()); } catch (NumberFormatException e) { return null; }\n}","tryCatchPattern":"try { return headers.getInt(name); } catch (UnsupportedOperationException e) { return safeGetInt(headers, name); }","preventionTips":["Prefer string-based get() on Vert.x HttpHeaders and parse yourself","Remember Vert.x Http1xHeaders omits netty-style numeric accessors","Centralize numeric header parsing in one utility"],"tags":["http","headers","unsupported","numeric"],"backgroundTag":"unsupported-operation","analyzedSha":"fb308bd8c3f12c79f4ae89bef67fadf6c80d036e","analyzedAt":"2026-09-06T11:37:12.241Z","contentChangedAt":"2026-09-06T11:37:12.241Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}