FunctionHandlerMapping needs to be defensive with debug flag

Spring Boot apps often run with --debug (no boolean value), so
we need to be defensive and not barf if it's empty (and therefore
not convertible to a boolean)
This commit is contained in:
Dave Syer
2017-06-28 15:07:07 +01:00
parent 78ca4df128
commit d1ccef62b5

View File

@@ -52,7 +52,7 @@ public class FunctionHandlerMapping extends RequestMappingHandlerMapping
private String prefix = ""; private String prefix = "";
@Value("${debug:${DEBUG:false}}") @Value("${debug:${DEBUG:false}}")
private boolean debug = false; private String debug = "false";
@Autowired @Autowired
public FunctionHandlerMapping(FunctionCatalog catalog, FunctionInspector inspector) { public FunctionHandlerMapping(FunctionCatalog catalog, FunctionInspector inspector) {
@@ -65,7 +65,7 @@ public class FunctionHandlerMapping extends RequestMappingHandlerMapping
@Override @Override
public void afterPropertiesSet() { public void afterPropertiesSet() {
super.afterPropertiesSet(); super.afterPropertiesSet();
this.controller.setDebug(debug); this.controller.setDebug(!"false".equals(debug));
detectHandlerMethods(controller); detectHandlerMethods(controller);
while (prefix.endsWith("/")) { while (prefix.endsWith("/")) {
prefix = prefix.substring(0, prefix.length() - 1); prefix = prefix.substring(0, prefix.length() - 1);