From 50b953780cc1cbbf5a18b8a7f0ee555ebbab4f86 Mon Sep 17 00:00:00 2001 From: Kengo TODA Date: Fri, 21 Mar 2014 09:14:15 +0800 Subject: [PATCH 1/2] upgrade JDK from 1.6 to 1.7 --- .travis.yml | 4 ++-- README.md | 6 +++++- pom.xml | 4 ++-- .../findbugs/jsr305/nullness/UnknownNullnessDetector.java | 8 ++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 17bb741..34c1631 100755 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: java jdk: - - openjdk6 + - openjdk7 script: "mvn clean install" after_success: - mvn clean test jacoco:report coveralls:jacoco @@ -8,4 +8,4 @@ notifications: email: recipients: - toda_k@worksap.co.jp - - li_yo@worksap.co.jp \ No newline at end of file + - li_yo@worksap.co.jp diff --git a/README.md b/README.md index c7f400c..2dedec5 100755 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ To use this product, please configure your findbugs-maven-plugin like below. jp.co.worksap.oss findbugs-plugin - 0.0.2 + 0.0.3-SNAPSHOT @@ -27,6 +27,10 @@ To use this product, please configure your findbugs-maven-plugin like below. # history +## 0.0.3 + +- upgraded JDK from 1.6 to 1.7 + ## 0.0.2 - added BrokenImmutableClassDetector diff --git a/pom.xml b/pom.xml index 6d936a8..4acfaba 100644 --- a/pom.xml +++ b/pom.xml @@ -38,8 +38,8 @@ maven-compiler-plugin - 1.6 - 1.6 + 1.7 + 1.7 ${project.build.sourceEncoding} diff --git a/src/main/java/jp/co/worksap/oss/findbugs/jsr305/nullness/UnknownNullnessDetector.java b/src/main/java/jp/co/worksap/oss/findbugs/jsr305/nullness/UnknownNullnessDetector.java index 5318cc2..30702af 100644 --- a/src/main/java/jp/co/worksap/oss/findbugs/jsr305/nullness/UnknownNullnessDetector.java +++ b/src/main/java/jp/co/worksap/oss/findbugs/jsr305/nullness/UnknownNullnessDetector.java @@ -66,9 +66,7 @@ private TypeQualifierAnnotation findDefaultAnnotation(XMethod xMethod, } else { return null; } - } catch (SecurityException e) { - throw new IllegalStateException(e); - } catch (IllegalAccessException e) { + } catch (SecurityException | IllegalAccessException e) { throw new IllegalStateException(e); } catch (InvocationTargetException e) { throw new IllegalArgumentException(e); @@ -93,9 +91,7 @@ private void detectUnknowNullnessOfReturnedValue(Method method, .getDeclaredMethod("getDefaultAnnotation", AnnotatedObject.class, TypeQualifierValue.class, ElementType.class); GET_DEFAULT_ANNOTATION.setAccessible(true); - } catch (SecurityException e) { - throw new IllegalStateException(e); - } catch (NoSuchMethodException e) { + } catch (SecurityException | NoSuchMethodException e) { throw new IllegalStateException(e); } } From 9cd2a17a466428f8ba50ff777e24df48a3d78cd6 Mon Sep 17 00:00:00 2001 From: Kengo TODA Date: Fri, 21 Mar 2014 09:36:40 +0800 Subject: [PATCH 2/2] add tests case to improve coverage. --- .../findbugs/jpa/GetterWithLongLengthAndLob.java | 14 ++++++++++++++ .../oss/findbugs/jpa/GetterWithTooLongLength.java | 12 ++++++++++++ .../oss/findbugs/jpa/GetterWithoutElement.java | 12 ++++++++++++ .../oss/findbugs/jpa/ImplicitLengthTest.java | 6 ++++++ .../oss/findbugs/jpa/ImplicitNullnessTest.java | 2 ++ .../oss/findbugs/jpa/NullableBooleanGetter.java | 14 ++++++++++++++ .../jpa/NullablePrimitiveDetectorTest.java | 5 ++++- .../worksap/oss/findbugs/jsr305/MutableClass.java | 2 ++ 8 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java create mode 100644 src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java create mode 100644 src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java create mode 100644 src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java new file mode 100644 index 0000000..652ba40 --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithLongLengthAndLob.java @@ -0,0 +1,14 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; +import javax.persistence.Lob; + +public class GetterWithLongLengthAndLob { + private String name; + + @Lob + @Column(length = 10000) + public String getName() { + return name; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java new file mode 100644 index 0000000..6b54cbc --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithTooLongLength.java @@ -0,0 +1,12 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; + +public class GetterWithTooLongLength { + private String name; + + @Column(length = 10000) + public String getName() { + return name; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java new file mode 100644 index 0000000..d175307 --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/GetterWithoutElement.java @@ -0,0 +1,12 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; + +public class GetterWithoutElement { + private String name; + + @Column + public String getName() { + return name; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java index 8a3b9ef..7a01985 100644 --- a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitLengthTest.java @@ -30,12 +30,16 @@ public void testNegativeLength() throws Exception { public void testTooLongLength() throws Exception { assertBugReported(ColumnWithTooLongLength.class, detector, bugReporter, ofType("ILLEGAL_LENGTH")); + assertBugReported(GetterWithTooLongLength.class, detector, + bugReporter, ofType("ILLEGAL_LENGTH")); } @Test public void testLongLengthWithLob() throws Exception { assertNoBugsReported(ColumnWithLongLengthAndLob.class, detector, bugReporter); + assertNoBugsReported(GetterWithLongLengthAndLob.class, detector, + bugReporter); } @Test @@ -48,5 +52,7 @@ public void testExplicitLength() throws Exception { public void testImplicitLength() throws Exception { assertBugReported(ColumnWithoutElement.class, detector, bugReporter, ofType("IMPLICIT_LENGTH")); + assertBugReported(GetterWithoutElement.class, detector, + bugReporter, ofType("IMPLICIT_LENGTH")); } } diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java index 1038896..109b92c 100644 --- a/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/ImplicitNullnessTest.java @@ -29,5 +29,7 @@ public void testExplicitNullness() throws Exception { public void testImplicitNullness() throws Exception { assertBugReported(ColumnWithoutElement.class, detector, bugReporter); + assertBugReported(GetterWithoutElement.class, detector, + bugReporter); } } diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java new file mode 100644 index 0000000..5b2f52b --- /dev/null +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullableBooleanGetter.java @@ -0,0 +1,14 @@ +package jp.co.worksap.oss.findbugs.jpa; + +import javax.persistence.Column; +import javax.persistence.Entity; + +@Entity +public class NullableBooleanGetter { + private boolean booleanValue; + + @Column(nullable = true) + public boolean isBooleanValue() { + return booleanValue; + } +} diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java index 1f9c8dc..46c33a9 100644 --- a/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jpa/NullablePrimitiveDetectorTest.java @@ -23,10 +23,11 @@ public void before() { @Test public void testNullableObject() throws Exception { assertNoBugsReported(UseColumnDefinition.class, detector, bugReporter); + assertNoBugsReported(ColumnWithoutElement.class, detector, bugReporter); } @Test - public void testNullableInt() throws Exception { + public void testNullablePrimitive() throws Exception { assertBugReported(NullableBooleanColumn.class, detector, bugReporter, ofType("NULLABLE_PRIMITIVE")); assertBugReported(NullableByteColumn.class, detector, @@ -41,6 +42,8 @@ public void testNullableInt() throws Exception { bugReporter, ofType("NULLABLE_PRIMITIVE")); assertBugReported(NullableDoubleColumn.class, detector, bugReporter, ofType("NULLABLE_PRIMITIVE")); + assertBugReported(NullableBooleanGetter.class, detector, + bugReporter, ofType("NULLABLE_PRIMITIVE")); } @Test diff --git a/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java b/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java index 73a1bcf..89d580d 100755 --- a/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java +++ b/src/test/java/jp/co/worksap/oss/findbugs/jsr305/MutableClass.java @@ -1,7 +1,9 @@ package jp.co.worksap.oss.findbugs.jsr305; import javax.annotation.concurrent.Immutable; +import javax.annotation.concurrent.NotThreadSafe; +@NotThreadSafe @Immutable // marked as immutable, but field is not final public class MutableClass { public String value;