{"record":{"id":"6516fd9c1ccab712","repo":"pentaho/pentaho-kettle","slug":"image-icon-file-name-can-not-be-null-swinggc","errorCode":null,"errorMessage":"Image icon file name can not be null","messagePattern":"Image icon file name can not be null","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/core/gui/SwingGC.java","lineNumber":249,"sourceCode":"    errorArrow = getImageIcon( BasePropertyHandler.getProperty( \"errorArrow_image\" ) );\n    disabledArrow = getImageIcon( BasePropertyHandler.getProperty( \"disabledArrow_image\" ) );\n\n    fontGraph = new Font( \"FreeSans\", Font.PLAIN, 10 );\n    fontNote = new Font( \"FreeSans\", Font.PLAIN, 10 );\n    fontSmall = new Font( \"FreeSans\", Font.PLAIN, 8 );\n\n    gc.setFont( fontGraph );\n\n    gc.setColor( background );\n    gc.fillRect( 0, 0, area.x, area.y );\n  }\n\n  private SwingUniversalImage getImageIcon( String fileName ) throws KettleException {\n    SwingUniversalImage image = null;\n\n    InputStream inputStream = null;\n    if ( fileName == null ) {\n      throw new KettleException( \"Image icon file name can not be null\" );\n    }\n\n    if ( SvgSupport.isSvgEnabled() && SvgSupport.isSvgName( fileName ) ) {\n      try {\n        inputStream = new FileInputStream( fileName );\n      } catch ( FileNotFoundException ex ) {\n        // no need to fail\n      }\n      if ( inputStream == null ) {\n        try {\n          inputStream = new FileInputStream( \"/\" + fileName );\n        } catch ( FileNotFoundException ex ) {\n          // no need to fail\n        }\n      }\n      if ( inputStream == null ) {\n        inputStream = getClass().getResourceAsStream( fileName );\n      }","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/core/gui/SwingGC.java#L231-L267","documentation":"SwingGC.getImageIcon(String fileName) — the SwingGraphics variant of the same loader — throws KettleException immediately when the requested image name is null, before attempting any file or SVG lookup.","triggerScenarios":"getImageIcon(null) during GC init; a null image path supplied by GUI code, e.g. a properties/plugin lookup that returned null for an icon key.","commonSituations":"Plugins with missing or misspelled image registrations; GUI resources not initialized before drawing; refactors that removed an image constant still referenced by init().","solutions":["Trace the null name to its source (constant, plugin.xml, properties) and supply the correct image name.","Guard the call site with a null check and fall back to a default icon.","Fix the plugin image registration so lookups return a valid path.","Initialize GUI/image properties before constructing the GC."],"exampleFix":"// before\ngc.getImageIcon( getIconName() ); // returns null -> KettleException\n// after\nString icon = getIconName();\nif (icon == null) { icon = DEFAULT_ICON; }\ngc.getImageIcon(icon);","handlingStrategy":"validation","validationCode":"if (iconName == null || iconName.isEmpty()) iconName = DEFAULT_ICON; // before GC init","typeGuard":"boolean isValidIconName(String s) { return s != null && !s.isEmpty(); }","tryCatchPattern":"try {\n  gc.getImageIcon(iconName);\n} catch (KettleException e) {\n  if (e.getMessage().contains(\"can not be null\")) { iconName = DEFAULT_ICON; }\n  else throw e;\n}","preventionTips":["Centralize icon name resolution in one null-safe helper.","Unit-test image lookups so missing registrations surface before GUI init.","Avoid passing raw properties values straight into image loaders.","Define all icon constants in one registry class."],"tags":["gui","swing","null-argument","kettle"],"backgroundTag":"null-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}