Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 2 additions & 1 deletion src/org/nutz/mvc/adaptor/injector/JsonInjector.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.lang.reflect.Type;
import java.util.Map;
import java.util.Objects;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
Expand Down Expand Up @@ -33,7 +34,7 @@ public Object get( ServletContext sc,
if (null == name)
return Mapl.maplistToObj(refer, type);

Map<String, Object> map = (Map<String, Object>)refer;
Map<String, Object> map = (Map<String, Object>) Objects.requireNonNull(refer, "refer");
Object theObj = map.get(name);
if (null == theObj)
return null;
Expand Down
24 changes: 24 additions & 0 deletions test/org/nutz/mvc/adaptor/injector/JsonInjectorTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.nutz.mvc.adaptor.injector;

import static org.junit.Assert.*;

import org.junit.Test;

/**
* @author Heewon Lee ([email protected])
*/
public class JsonInjectorTest {

@Test
public void test_null_refer() {
// 准备数据
JsonInjector inj = new JsonInjector(null, "");

// 检测
Throwable exc = assertThrows(NullPointerException.class, () -> {
inj.get(null, null, null, null);
});
assertEquals("refer", exc.getMessage());
}

}