Skip to content

Commit 19e77cd

Browse files
marschallsnicoll
authored andcommitted
Remove use of Boolean constructors
Codacy warns us that there are several references to Boolean constructors in the tests. Direct usage of the Boolean constructor is discouraged and even deprecated in Java 9 [1]. Boolean constructor use can easily be replaced with the constant instances. This commit contains the following changes: - replace references to Boolean constructors with boolean constants in JSP tag tests - update the copyright year where necessary - BooleanComparatorTests is intentionally left unchanged as it should also work with the non-constant instances correctly [1] http://download.java.net/java/jdk9/docs/api/java/lang/Boolean.html#Boolean-boolean- Issue: SPR-15076
1 parent 4cd9710 commit 19e77cd

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxTagTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ public void withSingleValueBooleanChecked() throws Exception {
164164

165165
@Test
166166
public void withSingleValueBooleanObjectUnchecked() throws Exception {
167-
this.bean.setSomeBoolean(new Boolean(false));
167+
this.bean.setSomeBoolean(Boolean.FALSE);
168168
this.tag.setPath("someBoolean");
169169
int result = this.tag.doStartTag();
170170
assertEquals(Tag.SKIP_BODY, result);
@@ -692,7 +692,7 @@ protected TestBean createTestBean() {
692692
this.bean.setDate(getDate());
693693
this.bean.setName("Rob Harrop");
694694
this.bean.setJedi(true);
695-
this.bean.setSomeBoolean(new Boolean(true));
695+
this.bean.setSomeBoolean(Boolean.TRUE);
696696
this.bean.setStringArray(new String[] {"bar", "foo"});
697697
this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
698698
this.bean.setOtherColours(colours);

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/CheckboxesTagTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -773,7 +773,7 @@ protected TestBean createTestBean() {
773773
this.bean.setDate(getDate());
774774
this.bean.setName("Rob Harrop");
775775
this.bean.setJedi(true);
776-
this.bean.setSomeBoolean(new Boolean(true));
776+
this.bean.setSomeBoolean(Boolean.TRUE);
777777
this.bean.setStringArray(new String[] {"bar", "foo"});
778778
this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
779779
this.bean.setOtherColours(colours);

spring-webmvc/src/test/java/org/springframework/web/servlet/tags/form/RadioButtonsTagTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2015 the original author or authors.
2+
* Copyright 2002-2016 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -620,7 +620,7 @@ protected TestBean createTestBean() {
620620
this.bean.setDate(getDate());
621621
this.bean.setName("Rob Harrop");
622622
this.bean.setJedi(true);
623-
this.bean.setSomeBoolean(new Boolean(true));
623+
this.bean.setSomeBoolean(Boolean.TRUE);
624624
this.bean.setStringArray(new String[] {"bar", "foo"});
625625
this.bean.setSomeIntegerArray(new Integer[] {new Integer(2), new Integer(1)});
626626
this.bean.setOtherColours(colours);

0 commit comments

Comments
 (0)