Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public class InstalledCode {
* @throws IllegalArgumentException if {@code name.length >} {@link #MAX_NAME_LENGTH}
*/
public InstalledCode(String name) {
if (name.length() > MAX_NAME_LENGTH) {
if (name != null && name.length() > MAX_NAME_LENGTH) {
String msg = String.format("name length (%d) is greater than %d (name[0:%s] = %s)",
name.length(), MAX_NAME_LENGTH, MAX_NAME_LENGTH, name.substring(0, MAX_NAME_LENGTH));
throw new IllegalArgumentException(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@

public class InstalledCodeTest {

@Test
public void testNullName() {
new InstalledCode(null);
}

@Test
public void testTooLongName() {
String longName = new String(new char[InstalledCode.MAX_NAME_LENGTH]).replace('\0', 'A');
Expand Down