From 0462d3acd1eccec6763a4d9e5c8ca7ba2d6ded0d Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 2 Oct 2013 11:25:27 +1000 Subject: [PATCH 1/8] Clean up type warnings --- zanata-war/src/main/java/org/zanata/dao/AccountDAO.java | 2 +- zanata-war/src/main/java/org/zanata/dao/ActivityDAO.java | 2 +- zanata-war/src/main/java/org/zanata/dao/PersonDAO.java | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/dao/AccountDAO.java b/zanata-war/src/main/java/org/zanata/dao/AccountDAO.java index b62879a143..ee423c57f7 100644 --- a/zanata-war/src/main/java/org/zanata/dao/AccountDAO.java +++ b/zanata-war/src/main/java/org/zanata/dao/AccountDAO.java @@ -157,6 +157,6 @@ public List getAllMergedAccounts(HAccount mergedInto) { "from HAccount as a where a.mergedInto = :mergedInto"); query.setParameter("mergedInto", mergedInto); query.setComment("AccountDAO.getAllMergedAccounts"); - return query.list(); + return (List) query.list(); } } diff --git a/zanata-war/src/main/java/org/zanata/dao/ActivityDAO.java b/zanata-war/src/main/java/org/zanata/dao/ActivityDAO.java index e44538b64c..b07b9049a5 100644 --- a/zanata-war/src/main/java/org/zanata/dao/ActivityDAO.java +++ b/zanata-war/src/main/java/org/zanata/dao/ActivityDAO.java @@ -98,7 +98,7 @@ public List findLatestActivities(long personId, int offset, query.setFirstResult(offset); query.setCacheable(true); query.setComment("activityDAO.findLatestActivities"); - return query.list(); + return (List) query.list(); } public int getActivityCountByActor(Long personId) { diff --git a/zanata-war/src/main/java/org/zanata/dao/PersonDAO.java b/zanata-war/src/main/java/org/zanata/dao/PersonDAO.java index 0ac3a0919b..8e91e71b7f 100644 --- a/zanata-war/src/main/java/org/zanata/dao/PersonDAO.java +++ b/zanata-war/src/main/java/org/zanata/dao/PersonDAO.java @@ -166,13 +166,13 @@ public boolean isUserInLanguageTeamWithRoles(HPerson person, .setParameter("language", language); if (isTranslator != null) { - q.setParameter("isTranslator", isTranslator.booleanValue()); + q.setParameter("isTranslator", isTranslator); } if (isReviewer != null) { - q.setParameter("isReviewer", isReviewer.booleanValue()); + q.setParameter("isReviewer", isReviewer); } if (isCoordinator != null) { - q.setParameter("isCoordinator", isCoordinator.booleanValue()); + q.setParameter("isCoordinator", isCoordinator); } q.setCacheable(false).setComment( @@ -188,7 +188,7 @@ public List getAllLanguageTeamMemberships(HPerson person) { .setParameter("person", person); q.setCacheable(false).setComment( "PersonDAO.getAllLanguageTeamMemberships"); - return q.list(); + return (List) q.list(); } } From 29d10f47bb70cadefafb38a570e7f16cf9eed6dd Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 2 Oct 2013 18:09:16 +1000 Subject: [PATCH 2/8] Fix findbugs warning --- .../zanata/webtrans/client/presenter/UserConfigHolder.java | 4 +++- .../webtrans/shared/validation/action/TabValidation.java | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/UserConfigHolder.java b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/UserConfigHolder.java index 7551fafcf4..887024a0e8 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/UserConfigHolder.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/client/presenter/UserConfigHolder.java @@ -33,6 +33,8 @@ import com.google.gwt.user.client.rpc.IsSerializable; import com.google.inject.Singleton; +import javax.annotation.Nonnull; + @Singleton public class UserConfigHolder { public static final Predicate INCOMPLETE_PREDICATE = @@ -46,7 +48,7 @@ public boolean apply(ContentState contentState) { public static final Predicate DRAFT_PREDICATE = new Predicate() { @Override - public boolean apply(ContentState contentState) { + public boolean apply(@Nonnull ContentState contentState) { return contentState.isRejectedOrFuzzy(); } }; diff --git a/zanata-war/src/main/java/org/zanata/webtrans/shared/validation/action/TabValidation.java b/zanata-war/src/main/java/org/zanata/webtrans/shared/validation/action/TabValidation.java index 1c1a2e964c..a04e83294b 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/shared/validation/action/TabValidation.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/shared/validation/action/TabValidation.java @@ -34,11 +34,11 @@ public TabValidation(ValidationId id, ValidationMessages messages) { super(id, messages.tabValidatorDesc(), messages); } + @edu.umd.cs.findbugs.annotations.SuppressWarnings("GBU_GUAVA_BETA_CLASS_USAGE") @Override public List doValidate(String source, String target) { ArrayList errors = new ArrayList(); - @edu.umd.cs.findbugs.annotations.SuppressWarnings("GBU_GUAVA_BETA_CLASS_USAGE") CharMatcher tabs = CharMatcher.is('\t'); int sourceTabs = tabs.countIn(source); int targetTabs = tabs.countIn(target); From 535b2e704a161e43d27d12f050409fd15eb9a5c6 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Thu, 3 Oct 2013 15:56:26 +1000 Subject: [PATCH 3/8] Sort by percent approved as double, not int --- .../zanata/action/ViewAllStatusAction.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/zanata-war/src/main/java/org/zanata/action/ViewAllStatusAction.java b/zanata-war/src/main/java/org/zanata/action/ViewAllStatusAction.java index 3d186bf93f..fb808e19ec 100644 --- a/zanata-war/src/main/java/org/zanata/action/ViewAllStatusAction.java +++ b/zanata-war/src/main/java/org/zanata/action/ViewAllStatusAction.java @@ -162,15 +162,16 @@ public Status(String locale, String nativeName, @Override public int compareTo(Status o) { - int per = - getStats().getTotal() == 0 ? 0 : (int) Math.ceil(100.0 - * getStats().getApproved() / getStats().getTotal()); - int comparePer = - o.getStats().getTotal() == 0 ? 0 : (int) Math.ceil(100.0 - * o.getStats().getApproved() - / o.getStats().getTotal()); - - return Double.compare(comparePer, per); + // TODO compare by locale too? + // TODO if totals are the same, we only need to compare approved + return Double.compare(o.getPercentApproved(), getPercentApproved()); + } + + private double getPercentApproved() { + // TODO move to TranslationStatistics.getPercentApproved() ? + long total = getStats().getTotal(); + long approved = getStats().getApproved(); + return total == 0 ? 0 : 100d * approved / total; } } From 68bf66992d02688c98642a3386c697c8a54ee2dc Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Thu, 3 Oct 2013 16:18:20 +1000 Subject: [PATCH 4/8] Fix findbugs warning --- .../org/zanata/webtrans/client/view/TransMemoryView.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java b/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java index b437c1548f..82f25ce9ca 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java @@ -308,7 +308,7 @@ public void renderTable(List memories, resultTable.getFlexCellFormatter().setStyleName(i + 1, NUM_TRANS_COL, "centered"); - if (i % 2 == 1) { + if (odd(i)) { resultTable.getRowFormatter().setStyleName(i + 1, "oddRow"); } @@ -358,6 +358,10 @@ public void onClick(ClickEvent event) { container.setWidget(resultTable); } + private boolean odd(int n) { + return n % 2 != 0; + } + @Override public void redrawTable(List memories) { for (int i = 0; i < memories.size(); i++) { From 256e4db337adbe312914c46586bc9a82d2628ef3 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Thu, 3 Oct 2013 17:41:12 +1000 Subject: [PATCH 5/8] Fix findbugs warnings --- .../org/zanata/hibernate/search/ConfigurableNgramAnalyzer.java | 1 + zanata-war/pom.xml | 1 - .../src/main/java/org/zanata/action/ReindexAsyncBean.java | 2 +- zanata-war/src/main/java/org/zanata/seam/FixedSafeActions.java | 1 + .../java/org/zanata/webtrans/client/view/TransMemoryView.java | 2 +- .../src/test/java/com/google/gwt/core/client/GWTBridge.java | 3 +++ 6 files changed, 7 insertions(+), 3 deletions(-) diff --git a/zanata-model/src/main/java/org/zanata/hibernate/search/ConfigurableNgramAnalyzer.java b/zanata-model/src/main/java/org/zanata/hibernate/search/ConfigurableNgramAnalyzer.java index 09fd430ce0..b6b8735b97 100644 --- a/zanata-model/src/main/java/org/zanata/hibernate/search/ConfigurableNgramAnalyzer.java +++ b/zanata-model/src/main/java/org/zanata/hibernate/search/ConfigurableNgramAnalyzer.java @@ -69,6 +69,7 @@ public ConfigurableNgramAnalyzer(int ngramMinLength, int ngramMaxLength, this.foldCase = foldCase; } + @SuppressWarnings("resource") // caller should close @Override public TokenStream tokenStream(String fieldName, Reader reader) { TokenStream tokenStream; diff --git a/zanata-war/pom.xml b/zanata-war/pom.xml index cdca91f718..3ab7a0b58e 100644 --- a/zanata-war/pom.xml +++ b/zanata-war/pom.xml @@ -108,7 +108,6 @@ javax.xml.bind:jaxb-api com.mattbertolini:liquibase-slf4j - com.google.code.findbugs:annotations quartz:quartz org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-api diff --git a/zanata-war/src/main/java/org/zanata/action/ReindexAsyncBean.java b/zanata-war/src/main/java/org/zanata/action/ReindexAsyncBean.java index 5ff4b23034..8cb93fc00d 100644 --- a/zanata-war/src/main/java/org/zanata/action/ReindexAsyncBean.java +++ b/zanata-war/src/main/java/org/zanata/action/ReindexAsyncBean.java @@ -193,7 +193,7 @@ public Boolean call() throws Exception { // look at updating isInProgress not to care about count if (getHandle().getMaxProgress() == 0) { log.info("Reindexing aborted because there are no actions to perform (may be indexing an empty table)"); - return null; + return false; } for (Class clazz : indexables) { if (!getHandle().isCancelled() diff --git a/zanata-war/src/main/java/org/zanata/seam/FixedSafeActions.java b/zanata-war/src/main/java/org/zanata/seam/FixedSafeActions.java index bead38459f..4d46648881 100644 --- a/zanata-war/src/main/java/org/zanata/seam/FixedSafeActions.java +++ b/zanata-war/src/main/java/org/zanata/seam/FixedSafeActions.java @@ -35,6 +35,7 @@ // Implementation copied from // https://source.jboss.org/browse/Seam/branches/community/Seam_2_3/jboss-seam/src/main/java/org/jboss/seam/navigation/SafeActions.java?r=14141 // following https://community.jboss.org/message/688860#688860 +// TODO see if this can be removed - see also https://issues.jboss.org/browse/JBSEAM-4800 public class FixedSafeActions extends org.jboss.seam.navigation.SafeActions { private Set safeActions = Collections diff --git a/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java b/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java index 82f25ce9ca..9a27552b42 100644 --- a/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java +++ b/zanata-war/src/main/java/org/zanata/webtrans/client/view/TransMemoryView.java @@ -358,7 +358,7 @@ public void onClick(ClickEvent event) { container.setWidget(resultTable); } - private boolean odd(int n) { + private static boolean odd(int n) { return n % 2 != 0; } diff --git a/zanata-war/src/test/java/com/google/gwt/core/client/GWTBridge.java b/zanata-war/src/test/java/com/google/gwt/core/client/GWTBridge.java index 674684752e..6f7e7eab70 100644 --- a/zanata-war/src/test/java/com/google/gwt/core/client/GWTBridge.java +++ b/zanata-war/src/test/java/com/google/gwt/core/client/GWTBridge.java @@ -1,5 +1,7 @@ package com.google.gwt.core.client; +import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; + /** * After upgrade to GWT 2.5, some of the gwt related libraries start to break. * i.e. gwt-log see http://code.google.com/p/gwt-log/issues/detail?id=70 @@ -11,5 +13,6 @@ * @author Patrick Huang pahuang@redhat.com */ +@SuppressFBWarnings("NM_SAME_SIMPLE_NAME_AS_SUPERCLASS") public abstract class GWTBridge extends com.google.gwt.core.shared.GWTBridge { } From 8c5e2095d3304cdcc314f28542f3f3f6494fe528 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Tue, 8 Oct 2013 13:09:17 +1000 Subject: [PATCH 6/8] Fix findbugs warnings --- .../java/org/zanata/model/HTermComment.java | 7 +++++- .../main/java/org/zanata/model/HTextFlow.java | 5 ----- .../org/zanata/model/HGlossaryEntryTest.java | 22 +++++++++---------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/zanata-model/src/main/java/org/zanata/model/HTermComment.java b/zanata-model/src/main/java/org/zanata/model/HTermComment.java index fd682717cf..2c2bf50440 100644 --- a/zanata-model/src/main/java/org/zanata/model/HTermComment.java +++ b/zanata-model/src/main/java/org/zanata/model/HTermComment.java @@ -20,6 +20,8 @@ */ package org.zanata.model; +import java.io.Serializable; + import javax.persistence.Column; import javax.persistence.Entity; import javax.persistence.GeneratedValue; @@ -30,6 +32,7 @@ import org.hibernate.annotations.Cache; import org.hibernate.annotations.CacheConcurrencyStrategy; import org.hibernate.annotations.Type; + import javax.validation.constraints.NotNull; import lombok.NoArgsConstructor; @@ -46,7 +49,9 @@ @Setter @NoArgsConstructor @ToString(of = "comment") -public class HTermComment { +public class HTermComment implements Serializable { + private static final long serialVersionUID = 1L; + private Long id; private String comment; diff --git a/zanata-model/src/main/java/org/zanata/model/HTextFlow.java b/zanata-model/src/main/java/org/zanata/model/HTextFlow.java index a2c0d84f93..fb90abf827 100644 --- a/zanata-model/src/main/java/org/zanata/model/HTextFlow.java +++ b/zanata-model/src/main/java/org/zanata/model/HTextFlow.java @@ -447,11 +447,6 @@ private void updateContentHash() { private String toBCP47(HLocale hLocale) { HLocale docLocale = document.getLocale(); - if (docLocale == null) { - // *should* only happen in tests - log.warn("null locale, assuming 'en'"); - return "en"; - } LocaleId docLocaleId = docLocale.getLocaleId(); return docLocaleId.getId(); } diff --git a/zanata-model/src/test/java/org/zanata/model/HGlossaryEntryTest.java b/zanata-model/src/test/java/org/zanata/model/HGlossaryEntryTest.java index 7a575001fc..c37e9a14dc 100644 --- a/zanata-model/src/test/java/org/zanata/model/HGlossaryEntryTest.java +++ b/zanata-model/src/test/java/org/zanata/model/HGlossaryEntryTest.java @@ -40,13 +40,13 @@ public class HGlossaryEntryTest { @BeforeTest public void setup() { entry = new HGlossaryEntry(); - entry.setId(new Long(1)); + entry.setId(1L); entry.setVersionNum(1); entry.setCreationDate(new Date()); entry.setLastChanged(new Date()); HLocale srcLang = new HLocale(LocaleId.EN_US); - setupHLocale(srcLang, new Long(1)); + setupHLocale(srcLang, 1L); entry.setSrcLocale(srcLang); entry.setSourceRef("source ref"); @@ -59,7 +59,7 @@ public void hashMapDataTerm1Test() { // Glossary Term 1 - EN_US HLocale term1Locale = - setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1)); + setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L); assertEquals(1, entry.getGlossaryTerms().size()); assertEquals(true, entry.getGlossaryTerms().containsKey(term1Locale)); @@ -74,11 +74,11 @@ public void hashMapDataTerm2Test() { // Glossary Term 1 - EN_US HLocale term1Locale = - setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1)); + setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L); // Glossary Term 2 - DE HLocale term2Locale = - setupTerm(new Long(2), "TERM 2", LocaleId.DE, new Long(2)); + setupTerm(2L, "TERM 2", LocaleId.DE, 2L); assertEquals(2, entry.getGlossaryTerms().size()); assertEquals(true, entry.getGlossaryTerms().containsKey(term2Locale)); @@ -93,15 +93,15 @@ public void hashMapDataTerm3Test() { // Glossary Term 1 - EN_US HLocale term1Locale = - setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1)); + setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L); // Glossary Term 2 - DE HLocale term2Locale = - setupTerm(new Long(2), "TERM 2", LocaleId.DE, new Long(2)); + setupTerm(2L, "TERM 2", LocaleId.DE, 2L); // Glossary Term 3 - ES HLocale term3Locale = - setupTerm(new Long(3), "TERM 3", LocaleId.ES, new Long(3)); + setupTerm(3L, "TERM 3", LocaleId.ES, 3L); assertEquals(3, entry.getGlossaryTerms().size()); assertEquals(true, entry.getGlossaryTerms().containsKey(term3Locale)); @@ -115,13 +115,13 @@ public void hashMapDataTest() { entry.getGlossaryTerms().clear(); // Glossary Term 1 - EN_US - setupTerm(new Long(1), "TERM 1", LocaleId.EN_US, new Long(1)); + setupTerm(1L, "TERM 1", LocaleId.EN_US, 1L); // Glossary Term 2 - DE - setupTerm(new Long(2), "TERM 2", LocaleId.DE, new Long(2)); + setupTerm(2L, "TERM 2", LocaleId.DE, 2L); // Glossary Term 3 - ES - setupTerm(new Long(3), "TERM 3", LocaleId.ES, new Long(3)); + setupTerm(3L, "TERM 3", LocaleId.ES, 3L); for (HLocale key : entry.getGlossaryTerms().keySet()) { assertTrue(entry.getGlossaryTerms().containsKey(key)); From 8f1a1e0742190239edaa86077ff21ff190402900 Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 12 Mar 2014 10:58:14 +1000 Subject: [PATCH 7/8] Isolate tests and run them in parallel --- zanata-war/pom.xml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/zanata-war/pom.xml b/zanata-war/pom.xml index 3ab7a0b58e..ca60419180 100644 --- a/zanata-war/pom.xml +++ b/zanata-war/pom.xml @@ -416,22 +416,17 @@ maven-surefire-plugin + 2.16 -Dconcordion.output.dir=${concordion.output.dir} none:none org.testng:testng - once - -Xmx1024m -XX:MaxPermSize=512m -XX:+UseConcMarkSweepGC - -XX:+CMSClassUnloadingEnabled -XX:+HeapDumpOnOutOfMemoryError - -XX:HeapDumpPath=${project.build.directory} -Dsun.lang.ClassLoader.allowArraySyntax=true + 1.5C + false src/test/resources/AllNonContainerTests.tng.xml alphabetical - From 6ee37fa12f25d77468f56b4191edffdfb155b94e Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 12 Mar 2014 14:17:33 +1000 Subject: [PATCH 8/8] Use input parameter instead of ignoring it; check for null locale again --- .../src/main/java/org/zanata/model/HTextFlow.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zanata-model/src/main/java/org/zanata/model/HTextFlow.java b/zanata-model/src/main/java/org/zanata/model/HTextFlow.java index 5c2edfd9c2..33547b3f14 100644 --- a/zanata-model/src/main/java/org/zanata/model/HTextFlow.java +++ b/zanata-model/src/main/java/org/zanata/model/HTextFlow.java @@ -447,8 +447,12 @@ private void updateContentHash() { this.setContentHash(HashUtil.generateHash(contents)); } - private String toBCP47(HLocale hLocale) { - HLocale docLocale = document.getLocale(); + private static String toBCP47(HLocale docLocale) { + if (docLocale == null) { + // *should* only happen in tests + log.warn("null locale, assuming 'en'"); + return "en"; + } LocaleId docLocaleId = docLocale.getLocaleId(); return docLocaleId.getId(); }