{"record":{"id":"ce7ccc3899ce5c09","repo":"libgdx/libgdx","slug":"extension-cannot-be-null","errorCode":null,"errorMessage":"extension cannot be null.","messagePattern":"extension cannot be null\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/audio/OpenALLwjglAudio.java","lineNumber":104,"sourceCode":"\t\tidleSources = new IntArray(allSources);\n\t\tsoundIdToSource = new LongMap<>();\n\t\tsourceToSoundId = new IntMap<>();\n\n\t\tFloatBuffer orientation = BufferUtils.createFloatBuffer(6).put(new float[] {0.0f, 0.0f, -1.0f, 0.0f, 1.0f, 0.0f});\n\t\t((Buffer)orientation).flip();\n\t\talListener(AL_ORIENTATION, orientation);\n\t\tFloatBuffer velocity = BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f});\n\t\t((Buffer)velocity).flip();\n\t\talListener(AL_VELOCITY, velocity);\n\t\tFloatBuffer position = BufferUtils.createFloatBuffer(3).put(new float[] {0.0f, 0.0f, 0.0f});\n\t\t((Buffer)position).flip();\n\t\talListener(AL_POSITION, position);\n\n\t\trecentSounds = new OpenALSound[simultaneousSources];\n\t}\n\n\tpublic void registerSound (String extension, Class<? extends OpenALSound> soundClass) {\n\t\tif (extension == null) throw new IllegalArgumentException(\"extension cannot be null.\");\n\t\tif (soundClass == null) throw new IllegalArgumentException(\"soundClass cannot be null.\");\n\t\textensionToSoundClass.put(extension, soundClass);\n\t}\n\n\tpublic void registerMusic (String extension, Class<? extends OpenALMusic> musicClass) {\n\t\tif (extension == null) throw new IllegalArgumentException(\"extension cannot be null.\");\n\t\tif (musicClass == null) throw new IllegalArgumentException(\"musicClass cannot be null.\");\n\t\textensionToMusicClass.put(extension, musicClass);\n\t}\n\n\tpublic OpenALSound newSound (FileHandle file) {\n\t\tString extension = file.extension().toLowerCase();\n\t\treturn newSound(file, extension);\n\t}\n\n\tpublic OpenALSound newSound (FileHandle file, String extension) {\n\t\tif (file == null) throw new IllegalArgumentException(\"file cannot be null.\");\n\t\tClass<? extends OpenALSound> soundClass = extensionToSoundClass.get(extension);","sourceCodeStart":86,"sourceCodeEnd":122,"githubUrl":"https://github.com/libgdx/libgdx/blob/97f40861878058087be0685ca167ddfde132134b/backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/audio/OpenALLwjglAudio.java#L86-L122","documentation":"A plain argument-contract IllegalArgumentException from OpenALLwjglAudio.registerSound(extension, soundClass): the extension key that maps a file type to an OpenALSound implementation must not be null, otherwise the registry map would contain an unusable null key. It fires before the map write.","triggerScenarios":"Calling audio.registerSound(null, Wav.Sound.class) — typically a variable that was supposed to hold a file extension (\"ogg\", \"mp3\", \"wav\") but was never assigned, or a lookup that returned null and was passed through unchecked.","commonSituations":"Custom backend extensions or asset pipelines that derive the extension at runtime (e.g. from a config entry) and pass a missing value; refactors that rename the extension constant leaving a null reference.","solutions":["Pass a literal lowercase extension string: registerSound(\"ogg\", Ogg.Sound.class).","Trace where the extension variable comes from and default it (e.g. from FileHandle.extension()) before registering.","Add a null/format check in your own registration helper so misconfiguration fails with a clearer message."],"exampleFix":"// before\nString ext = config.get(\"soundExt\"); // null when key missing\naudio.registerSound(ext, MySound.class);\n\n// after\nString ext = config.get(\"soundExt\", \"wav\");\naudio.registerSound(ext.toLowerCase(), MySound.class);","handlingStrategy":"validation","validationCode":"boolean validExtension(String ext) {\n  return ext != null && ext.matches(\"[a-z0-9]+\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass literal lowercase extensions","Default missing config values instead of forwarding null","Check argument order: (extension, class)"],"tags":["audio","validation","illegal-argument","registration"],"backgroundTag":null,"analyzedSha":"97f40861878058087be0685ca167ddfde132134b","analyzedAt":"2026-08-14T10:52:53.492Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}