Skip to content

Commit

Permalink
refactor: remove warnings in zanata-war
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed May 5, 2017
1 parent 373fa73 commit a6d9de4
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 57 deletions.
1 change: 0 additions & 1 deletion client/pom.xml
Expand Up @@ -48,7 +48,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<onlyAnalyze>org.zanata.-</onlyAnalyze>
<failOnError>true</failOnError>
</configuration>
</plugin>
Expand Down
1 change: 0 additions & 1 deletion common/pom.xml
Expand Up @@ -43,7 +43,6 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<onlyAnalyze>org.zanata.-</onlyAnalyze>
<failOnError>true</failOnError>
</configuration>
</plugin>
Expand Down
9 changes: 0 additions & 9 deletions server/pom.xml
Expand Up @@ -2062,15 +2062,6 @@
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<configuration>
<onlyAnalyze>org.zanata.-</onlyAnalyze>
<failOnError>true</failOnError>
</configuration>
</plugin>
</plugins>

<pluginManagement>
Expand Down
Expand Up @@ -157,19 +157,15 @@ public void setInstance(final HCopyTransOptions instance) {
this.instance = instance;
}

public List<RuleAction> getRuleActions() {
public synchronized List<RuleAction> getRuleActions() {
Object value = this.ruleActions.get();
if (value == null) {
synchronized (this.ruleActions) {
value = this.ruleActions.get();
if (value == null) {
final List<RuleAction> actualValue = getRuleActionsList();
value = actualValue == null ? this.ruleActions
: actualValue;
this.ruleActions.set(value);
}
}
final List<RuleAction> actualValue = getRuleActionsList();
value = actualValue == null ? this.ruleActions
: actualValue;
this.ruleActions.set(value);
}
return (List<RuleAction>) (value == this.ruleActions ? null : value);
return (List<RuleAction>) (value == this.ruleActions ? null :
value);
}
}
Expand Up @@ -1302,17 +1302,12 @@ public void setSelectedCheckbox(final Boolean selectedCheckbox) {
this.selectedCheckbox = selectedCheckbox;
}

public List<HProjectIteration> getVersions() {
public synchronized List<HProjectIteration> getVersions() {
Object value = this.versions.get();
if (value == null) {
synchronized (this.versions) {
value = this.versions.get();
if (value == null) {
final List<HProjectIteration> actualValue = fetchVersions();
value = actualValue;
this.versions.set(value);
}
}
final List<HProjectIteration> actualValue = fetchVersions();
value = actualValue;
this.versions.set(value);
}
return (List<HProjectIteration>) (value == this.versions ? null
: value);
Expand Down
Expand Up @@ -183,11 +183,11 @@ public ZanataCredentials getCredentials() {
return credentials;
}

public Subject getSubject() {
public synchronized Subject getSubject() {
return subject;
}

public void acceptExternallyAuthenticatedPrincipal(Principal principal) {
public synchronized void acceptExternallyAuthenticatedPrincipal(Principal principal) {
if (principal != null) {
getSubject().getPrincipals().add(principal);
}
Expand All @@ -200,7 +200,7 @@ public void acceptExternallyAuthenticatedPrincipal(Principal principal) {
* example when spawing a new thread for an async task, or when
* authenticating externally through Kerberos.
*/
public void acceptExternalSubjectAndPpal(Subject subject,
public synchronized void acceptExternalSubjectAndPpal(Subject subject,
Principal principal) {
this.subject = subject;
acceptExternallyAuthenticatedPrincipal(principal);
Expand Down Expand Up @@ -279,7 +279,7 @@ public void checkRole(String role) {
/**
* Resets all security state and credentials
*/
public void unAuthenticate() {
public synchronized void unAuthenticate() {
principal = null;
subject = new Subject();

Expand Down Expand Up @@ -403,7 +403,7 @@ private Event<NotLoggedInEvent> getNotLoggedInEvent() {
}

// copied from org.jboss.seam.security.Identity.tryLogin()
public boolean tryLogin() {
public synchronized boolean tryLogin() {
if (!authenticating && getPrincipal() == null && credentials.isSet() &&
Contexts.isRequestContextActive() &&
!requestContextValueStore.contains(LOGIN_TRIED)) {
Expand Down Expand Up @@ -681,7 +681,7 @@ public String getAccountUsername() {
return null;
}

public Principal getPrincipal() {
public synchronized Principal getPrincipal() {
return principal;
}

Expand Down
Expand Up @@ -79,19 +79,19 @@ public synchronized int get(ContentState state) {
}

public synchronized void add(AbstractStatistic other) {
this.approved += other.approved;
this.needReview += other.needReview;
this.untranslated += other.untranslated;
this.translated += other.translated;
this.rejected += other.rejected;
approved += other.getApproved();
needReview += other.getNeedReview();
untranslated += other.getUntranslated();
translated += other.getTranslated();
rejected += other.getRejected();
}

protected void set(AbstractStatistic other) {
this.approved = other.approved;
this.needReview = other.needReview;
this.untranslated = other.untranslated;
this.translated = other.translated;
this.rejected = other.rejected;
protected synchronized void set(AbstractStatistic other) {
approved = other.getApproved();
needReview = other.getNeedReview();
untranslated = other.getUntranslated();
translated = other.getTranslated();
rejected = other.getRejected();
}

public synchronized int getTotal() {
Expand Down Expand Up @@ -173,9 +173,9 @@ public synchronized boolean equals(Object obj) {
return false;
if (obj instanceof AbstractStatistic) {
AbstractStatistic o = (AbstractStatistic) obj;
return (approved == o.approved && needReview == o.needReview
&& untranslated == o.untranslated
&& translated == o.translated && rejected == o.rejected);
return (approved == o.getApproved() && needReview == o.getNeedReview()
&& untranslated == o.getUntranslated()
&& translated == o.getTranslated() && rejected == o.getRejected());
}
return false;
}
Expand Down
Expand Up @@ -39,12 +39,10 @@ public class TranslationUpdateListenerLazyLoader implements
private TranslationUpdateListener delegate;

public void init() {
if (delegate == null) {
synchronized (this) {
if (delegate == null) {
delegate = ServiceLocator.instance()
.getInstance(TranslationUpdateListener.class);
}
synchronized (this) {
if (delegate == null) {
delegate = ServiceLocator.instance()
.getInstance(TranslationUpdateListener.class);
}
}
}
Expand Down

0 comments on commit a6d9de4

Please sign in to comment.