From ca6b1a567c4ed3db35591018edd8b6ac55222a21 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 15:12:21 +0900 Subject: [PATCH 01/20] Remove redundant null-check We don't need it because play.configuration.root() never returns null. --- app/utils/Config.java | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/app/utils/Config.java b/app/utils/Config.java index 685af29b5..9db1b4095 100644 --- a/app/utils/Config.java +++ b/app/utils/Config.java @@ -56,10 +56,6 @@ public static String getSiteName() { public static String getHostport(String defaultValue) { play.Configuration config = play.Configuration.root(); - if (config == null) { - return defaultValue; - } - String hostname = play.Configuration.root().getString("application.hostname"); if (hostname != null && !hostname.isEmpty()) { @@ -106,11 +102,9 @@ private static InetAddress getDefaultAddress() throws SocketException, UnknownHo public static String getHostname() { play.Configuration config = play.Configuration.root(); - if (config != null) { - String hostname = play.Configuration.root().getString("application.hostname"); - if (hostname != null && !hostname.isEmpty()) { - return hostname; - } + String hostname = play.Configuration.root().getString("application.hostname"); + if (hostname != null && !hostname.isEmpty()) { + return hostname; } try { @@ -139,10 +133,6 @@ public static String getHostport() { public static String getScheme(String defaultValue) { play.Configuration config = play.Configuration.root(); - if (config == null) { - return defaultValue; - } - String scheme = config.getString("application.scheme"); if (scheme == null || scheme.isEmpty()) { From 56315fff5d296dfb4c6becfb68060ca0d6557f45 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 15:17:10 +0900 Subject: [PATCH 02/20] Fix possible NPE of rm_rf() Throw an exception if File.listFiles() returns null. --- app/controllers/ImportApp.java | 2 +- app/playRepository/GitRepository.java | 4 ++-- app/playRepository/PlayRepository.java | 2 +- app/playRepository/RepositoryService.java | 5 ++--- app/playRepository/SVNRepository.java | 2 +- app/utils/FileUtil.java | 5 ++++- test/controllers/ProjectAppTest.java | 4 ++-- test/models/CodeCommentThreadTest.java | 3 +-- test/models/PullRequestTest.java | 6 ++---- 9 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/controllers/ImportApp.java b/app/controllers/ImportApp.java index e02d48a17..461bdd14c 100644 --- a/app/controllers/ImportApp.java +++ b/app/controllers/ImportApp.java @@ -57,7 +57,7 @@ public static Result importForm() { } @Transactional - public static Result newProject() throws GitAPIException, IOException { + public static Result newProject() throws Exception { if( !AccessControl.isGlobalResourceCreatable(UserApp.currentUser()) ){ return forbidden("'" + UserApp.currentUser().name + "' has no permission"); } diff --git a/app/playRepository/GitRepository.java b/app/playRepository/GitRepository.java index ffd5d63bc..9a3b75c37 100644 --- a/app/playRepository/GitRepository.java +++ b/app/playRepository/GitRepository.java @@ -162,7 +162,7 @@ public static Repository buildGitRepository(Project project, boolean alternatesM } public static void cloneLocalRepository(Project originalProject, Project forkProject) - throws IOException, GitAPIException { + throws Exception { try { cloneHardLinkedRepository(originalProject, forkProject); } catch (Exception e) { @@ -638,7 +638,7 @@ public byte[] getRawFile(String revision, String path) throws IOException { * initializing {@code Cache} used in the repository. */ @Override - public void delete() { + public void delete() throws Exception { repository.close(); WindowCacheConfig config = new WindowCacheConfig(); config.install(); diff --git a/app/playRepository/PlayRepository.java b/app/playRepository/PlayRepository.java index c63086f32..d27fb9096 100644 --- a/app/playRepository/PlayRepository.java +++ b/app/playRepository/PlayRepository.java @@ -42,7 +42,7 @@ public interface PlayRepository { public abstract byte[] getRawFile(String revision, String path) throws IOException, SVNException; - public abstract void delete(); + public abstract void delete() throws Exception; public abstract String getPatch(String commitId) throws IOException, SVNException; diff --git a/app/playRepository/RepositoryService.java b/app/playRepository/RepositoryService.java index 609d78b8d..f1e5c321a 100644 --- a/app/playRepository/RepositoryService.java +++ b/app/playRepository/RepositoryService.java @@ -59,7 +59,7 @@ public static Map vcsTypes() { * @see {@link playRepository.PlayRepository#delete()} */ public static void deleteRepository(Project project) - throws IOException, ServletException { + throws Exception { RepositoryService.getRepository(project).delete(); } @@ -67,8 +67,7 @@ public static void deleteRepository(Project project) * @see {@link #deleteRepository(Project)} * @see {@link PlayRepository#create()} */ - public static void createRepository(Project project) throws IOException, ServletException, - UnsupportedOperationException, SVNException { + public static void createRepository(Project project) throws Exception { RepositoryService.deleteRepository(project); RepositoryService.getRepository(project).create(); } diff --git a/app/playRepository/SVNRepository.java b/app/playRepository/SVNRepository.java index 07804796f..5db8b36b1 100644 --- a/app/playRepository/SVNRepository.java +++ b/app/playRepository/SVNRepository.java @@ -210,7 +210,7 @@ public void create() throws SVNException { } @Override - public void delete() { + public void delete() throws Exception { FileUtil.rm_rf(new File(getRepoPrefix() + ownerName + "/" + projectName)); } diff --git a/app/utils/FileUtil.java b/app/utils/FileUtil.java index 29eb55f28..0a1f1cc17 100644 --- a/app/utils/FileUtil.java +++ b/app/utils/FileUtil.java @@ -34,9 +34,12 @@ public class FileUtil { public static final int MAX_SIZE_FOR_BINARY_DETECTION = 512; - public static void rm_rf(File file){ + public static void rm_rf(File file) throws Exception { if(file.isDirectory()){ File[] list = file.listFiles(); + if (list == null) { + throw new Exception("Unexpected error while deleting: " + file); + } for (File f : list) { rm_rf(f); } diff --git a/test/controllers/ProjectAppTest.java b/test/controllers/ProjectAppTest.java index a50a1a9c7..28256d293 100644 --- a/test/controllers/ProjectAppTest.java +++ b/test/controllers/ProjectAppTest.java @@ -436,7 +436,7 @@ public void testTransferProjectToWrongUser() { } @Test - public void testAcceptTransfer() throws IOException, ServletException, SVNException { + public void testAcceptTransfer() throws Exception { //Given GitRepository.setRepoPrefix("resources/test/repo/git/"); @@ -462,7 +462,7 @@ public void testAcceptTransfer() throws IOException, ServletException, SVNExcept } @Test - public void testAcceptTransferWithWrongKey() throws IOException, ServletException, SVNException { + public void testAcceptTransferWithWrongKey() throws Exception { //Given GitRepository.setRepoPrefix("resources/test/repo/git/"); diff --git a/test/models/CodeCommentThreadTest.java b/test/models/CodeCommentThreadTest.java index d22419e76..560be1993 100644 --- a/test/models/CodeCommentThreadTest.java +++ b/test/models/CodeCommentThreadTest.java @@ -28,7 +28,6 @@ import org.junit.Test; import playRepository.BareCommit; import playRepository.GitRepository; -import support.Git; import utils.JodaDateUtil; import java.io.File; @@ -55,7 +54,7 @@ public void before() throws IOException, GitAPIException { } @After - public void after() { + public void after() throws Exception { rm_rf(new File(REPO_PREFIX)); } diff --git a/test/models/PullRequestTest.java b/test/models/PullRequestTest.java index 797529a8c..a266d6ca7 100644 --- a/test/models/PullRequestTest.java +++ b/test/models/PullRequestTest.java @@ -20,7 +20,6 @@ */ package models; -import errors.PullRequestException; import org.apache.commons.lang3.time.DateUtils; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; @@ -65,8 +64,7 @@ public class PullRequestTest extends ModelTest { private Project forkedProject; @Before - public void initRepositories() throws IOException, GitAPIException, ServletException, - PullRequestException, SVNException { + public void initRepositories() throws Exception { GitRepository.setRepoPrefix(REPO_PREFIX); app = support.Helpers.makeTestApplication(); @@ -124,7 +122,7 @@ public void initRepositories() throws IOException, GitAPIException, ServletExcep } @After - public void after() { + public void after() throws Exception { rm_rf(new File(REPO_PREFIX)); rm_rf(new File(LOCAL_REPO_PREFIX)); Helpers.stop(app); From 16436e7040ee372f27d61e72273e70da0d362021 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 15:20:31 +0900 Subject: [PATCH 03/20] Remove redundant codes The method should just return httpSession because it is always nonnull. --- app/utils/PlayServletRequest.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/app/utils/PlayServletRequest.java b/app/utils/PlayServletRequest.java index 36487df95..b0abd5a2a 100644 --- a/app/utils/PlayServletRequest.java +++ b/app/utils/PlayServletRequest.java @@ -516,15 +516,7 @@ public HttpSession getSession() { @Override public HttpSession getSession(boolean create) { - if (httpSession != null) { - return httpSession; - } - - if (create) { - return new PlayServletSession(new PlayServletContext()); - } else { - return null; - } + return httpSession; } @Override From 61e1d1091131d793235cef58c44653cae49a832e Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 15:26:29 +0900 Subject: [PATCH 04/20] Rename merger to mergeResult --- app/models/PullRequest.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/PullRequest.java b/app/models/PullRequest.java index a3803cf08..e4a90cedf 100644 --- a/app/models/PullRequest.java +++ b/app/models/PullRequest.java @@ -570,9 +570,9 @@ public String fetchSourceBranch() throws IOException, GitAPIException { return destination; } - public void updateMergedCommitId(Merger.MergeResult merger) { - mergedCommitIdFrom = merger.getLeftParentId().getName(); - mergedCommitIdTo = merger.getMergeCommitId().getName(); + public void updateMergedCommitId(Merger.MergeResult mergeResult) { + mergedCommitIdFrom = mergeResult.getLeftParentId().getName(); + mergedCommitIdTo = mergeResult.getMergeCommitId().getName(); update(); } From 0fa962b005a38b4a0d468d8638448bd9ef9be37f Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 15:50:04 +0900 Subject: [PATCH 05/20] Remove redundant null-check --- app/models/Issue.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/Issue.java b/app/models/Issue.java index 60696e5e4..15dae288a 100644 --- a/app/models/Issue.java +++ b/app/models/Issue.java @@ -371,7 +371,7 @@ public boolean assignedUserEquals(Assignee otherAssignee) { return otherAssignee == null || otherAssignee.user == null || otherAssignee.user.isAnonymous(); } if (otherAssignee == null || otherAssignee.user == null || otherAssignee.user.isAnonymous()) { - return assignee == null || assignee.user == null || assignee.user.isAnonymous(); + return assignee.user.isAnonymous(); } return assignee.equals(otherAssignee) || assignee.user.equals(otherAssignee.user); } From c65b866e2cc05d3bbdf361f328ee010f7dd338c3 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 16:08:07 +0900 Subject: [PATCH 06/20] Fix incorrect string format --- app/playRepository/GitRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/playRepository/GitRepository.java b/app/playRepository/GitRepository.java index 9a3b75c37..b0c6f93f5 100644 --- a/app/playRepository/GitRepository.java +++ b/app/playRepository/GitRepository.java @@ -1065,8 +1065,8 @@ public static Set getRelatedAuthors(Repository repository, String revA, St if (diffs.size() > BLAME_FILE_LIMIT) { String msg = String.format("Reject to get related authors " + "from changes because of performance issue: The " + - "changes include %n files and it exceeds our limit " + - "of '%n' files.", diffs.size(), BLAME_FILE_LIMIT); + "changes include %d files and it exceeds our limit " + + "of '%d' files.", diffs.size(), BLAME_FILE_LIMIT); throw new LimitExceededException(msg); } From c79fb9784f2e630817de2fc1ce59a3a66a10a0f0 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 16:11:39 +0900 Subject: [PATCH 07/20] Property: Make sure check() returns nonnull list --- app/models/Property.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/Property.java b/app/models/Property.java index 9598d6263..70009942e 100644 --- a/app/models/Property.java +++ b/app/models/Property.java @@ -24,6 +24,7 @@ import play.db.ebean.Model; import utils.Diagnostic; +import javax.annotation.Nonnull; import javax.persistence.Entity; import javax.persistence.EnumType; import javax.persistence.Enumerated; @@ -91,7 +92,7 @@ public static enum Name { public static void onStart() { Diagnostic.register(new Diagnostic() { @Override - public List check() { + public @Nonnull List check() { List errors = new ArrayList<>(); for (Property.Name name : Property.Name.values()) { From e6541f9dbbf32ee76c9745f72da6b78219f601a1 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 10 Feb 2015 16:12:24 +0900 Subject: [PATCH 08/20] Fix incorrect comparision They should be compared by equals() method. --- app/controllers/BoardApp.java | 3 ++- app/controllers/ImportApp.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/BoardApp.java b/app/controllers/BoardApp.java index 13d175c6c..c4820e06b 100644 --- a/app/controllers/BoardApp.java +++ b/app/controllers/BoardApp.java @@ -55,6 +55,7 @@ import java.io.IOException; import java.util.List; +import java.util.Objects; import static com.avaje.ebean.Expr.icontains; @@ -244,7 +245,7 @@ public void run() { private static void unmarkAnotherReadmePostingIfExists(Project project, Long postingNumber) { Posting previousReadmePosting = Posting.findREADMEPosting(project); - if(previousReadmePosting != null && previousReadmePosting.getNumber() != postingNumber){ + if(previousReadmePosting != null && !Objects.equals(previousReadmePosting.getNumber(), postingNumber)){ previousReadmePosting.readme = false; previousReadmePosting.directSave(); } diff --git a/app/controllers/ImportApp.java b/app/controllers/ImportApp.java index 461bdd14c..715cd0fd7 100644 --- a/app/controllers/ImportApp.java +++ b/app/controllers/ImportApp.java @@ -42,6 +42,7 @@ import java.io.File; import java.io.IOException; import java.util.List; +import java.util.Objects; import static play.data.Form.form; @@ -180,7 +181,7 @@ private static ValidationResult validateForm(Form newProjectForm, Organ result = badRequest(create.render("title.newProject", newProjectForm, orgUserList)); } - if (ownerIsUser && UserApp.currentUser().id != user.id) { + if (ownerIsUser && !Objects.equals(UserApp.currentUser().id, user.id)) { newProjectForm.reject("owner", "project.owner.invalidate"); hasError = true; result = badRequest(create.render("title.newProject", newProjectForm, orgUserList)); From 91e3e7c406b0d680e4b05c8b10fb542d59983b0c Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 24 Feb 2015 11:21:02 +0900 Subject: [PATCH 09/20] Add missed assignments --- app/controllers/CodeHistoryApp.java | 2 +- app/controllers/IssueApp.java | 2 +- app/models/resource/Resource.java | 2 +- app/models/support/SearchCondition.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/controllers/CodeHistoryApp.java b/app/controllers/CodeHistoryApp.java index 24cda5066..d54a258c7 100644 --- a/app/controllers/CodeHistoryApp.java +++ b/app/controllers/CodeHistoryApp.java @@ -98,7 +98,7 @@ public static Result show(String ownerName, String projectName, String commitId) Project project = Project.findByOwnerAndProjectName(ownerName, projectName); PlayRepository repository = RepositoryService.getRepository(project); - Commit commit = null; + Commit commit; try { commit = repository.getCommit(commitId); diff --git a/app/controllers/IssueApp.java b/app/controllers/IssueApp.java index 34d509b3a..a8b933214 100644 --- a/app/controllers/IssueApp.java +++ b/app/controllers/IssueApp.java @@ -312,7 +312,7 @@ public static Result massUpdate(String ownerName, String projectName) { if(hasAssignee(issue)) { oldAssignee = issue.assignee.user; } - Assignee newAssignee = null; + Assignee newAssignee; if (issueMassUpdate.assignee.isAnonymous()) { newAssignee = null; } else { diff --git a/app/models/resource/Resource.java b/app/models/resource/Resource.java index a2d1ee1e9..2211db072 100644 --- a/app/models/resource/Resource.java +++ b/app/models/resource/Resource.java @@ -258,7 +258,7 @@ public static Resource findByPath(String path) { return null; } - ResourceType resourceType = null; + ResourceType resourceType; try { resourceType = ResourceType.getValue(segments[0]); diff --git a/app/models/support/SearchCondition.java b/app/models/support/SearchCondition.java index de787294e..b8f329110 100644 --- a/app/models/support/SearchCondition.java +++ b/app/models/support/SearchCondition.java @@ -256,7 +256,7 @@ public ExpressionList asExpressionList(Project project) { Junction junction = el.disjunction(); junction.icontains("title", filter) .icontains("body", filter); - List ids = null; + List ids; if( project == null){ ids = Issue.finder.where() .icontains("comments.contents", filter).findIds(); From bace3077a5ee63ce6e18b287eefcc672a7b23dcd Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Sun, 15 Feb 2015 11:05:06 +0900 Subject: [PATCH 10/20] Fix possible NPE Use StringUtils instead of custom equals because it might cause NPE. --- app/utils/TemplateHelper.scala | 7 +++---- app/views/code/svnDiff.scala.html | 3 ++- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/utils/TemplateHelper.scala b/app/utils/TemplateHelper.scala index 653528759..19c8b1eb8 100644 --- a/app/utils/TemplateHelper.scala +++ b/app/utils/TemplateHelper.scala @@ -1,5 +1,6 @@ package utils +import org.apache.commons.lang3.StringUtils import play.mvc.Call import org.joda.time.DateTimeConstants import org.apache.commons.io.FilenameUtils @@ -105,10 +106,8 @@ object TemplateHelper { } } - def equals(a: String, b: String) = (a == b) || a.equals(b) - def equalsThen(a: String, b: String, thenStr: String): String = { - if(a != null && b != null && equals(a, b)){ + if(a != null && b != null && StringUtils.equals(a, b)){ thenStr } else { "" @@ -125,7 +124,7 @@ object TemplateHelper { // Whether the given uris are pointing the same resource. def resourceEquals(a: URI, b: URI) = - nullOrEquals(a.getHost, b.getHost) && getPort(a) == getPort(b) && equals(a.getPath, b.getPath) + nullOrEquals(a.getHost, b.getHost) && getPort(a) == getPort(b) && StringUtils.equals(a.getPath, b.getPath) // Get the url to return to the list page from the view page. // Return the referrer if the it is the uri for the list page, an/ return the diff --git a/app/views/code/svnDiff.scala.html b/app/views/code/svnDiff.scala.html index 683e96bb7..936e405ad 100644 --- a/app/views/code/svnDiff.scala.html +++ b/app/views/code/svnDiff.scala.html @@ -27,6 +27,7 @@ @import utils.AccessControl._ @import play.libs.Json.toJson @import utils.Markdown +@import org.apache.commons.lang3.StringUtils @projectLayout(Messages("code.commits") + " @" + commit.getId, project, utils.MenuType.CODE) { @projectMenu(project, utils.MenuType.CODE, "main-menu-only") @@ -42,7 +43,7 @@ @defining(RepositoryService.getRepository(project).getBranchNames()) { branches => @for(branch <- branches){ @common.branchItem("history", project, branch, null, - utils.TemplateHelper.equals(branch, selectedBranch)) + StringUtils.equals(branch, selectedBranch)) } } From 2232c5185f5d95d069a0dabf54b7cfb767d52c5c Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Sun, 15 Feb 2015 11:21:43 +0900 Subject: [PATCH 11/20] Fix possible NPE --- app/utils/TemplateHelper.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/utils/TemplateHelper.scala b/app/utils/TemplateHelper.scala index 19c8b1eb8..9a0dddc4d 100644 --- a/app/utils/TemplateHelper.scala +++ b/app/utils/TemplateHelper.scala @@ -519,7 +519,7 @@ object TemplateHelper { } def getCorrectedPath(filePath:String, fileName:String):String = { - if((filePath != "") && (filePath.substring(filePath.length() - 1) == "/")){ + if(StringUtils.isNotEmpty(filePath) && (filePath.substring(filePath.length() - 1) == "/")){ filePath + fileName } else { filePath + "/" + fileName From ac83c23715cd4632ed43faca3250a037bebc89ae Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Sun, 15 Feb 2015 11:39:41 +0900 Subject: [PATCH 12/20] Fix reliance on default encoding For the Yobi's default encoding, use the encoding from Config.getCharset(), which returns always "UTF-8", instead of Charset.defaultCharset() which depends on the platform. --- app/Global.java | 6 +++--- app/playRepository/BareCommit.java | 15 +++++++++------ app/playRepository/BareRepository.java | 6 +++--- app/playRepository/SVNRepository.java | 14 ++++++-------- app/utils/BasicAuthAction.java | 2 +- app/utils/Config.java | 5 +++++ app/utils/Markdown.java | 7 ++++--- app/utils/MomentUtil.java | 2 +- app/utils/PlayServletResponse.java | 5 ++++- 9 files changed, 36 insertions(+), 26 deletions(-) diff --git a/app/Global.java b/app/Global.java index 0549b8d1b..1ded38568 100644 --- a/app/Global.java +++ b/app/Global.java @@ -162,14 +162,14 @@ private String createSeed(String basicSeed) { } private void replaceSiteSecretKey(String seed) throws IOException { - SecureRandom random = new SecureRandom(seed.getBytes()); + SecureRandom random = new SecureRandom(seed.getBytes(Config.getCharset())); String secret = new BigInteger(130, random).toString(32); Path path = Paths.get("conf/application.conf"); byte[] bytes = Files.readAllBytes(path); - String config = new String(bytes); + String config = new String(bytes, Config.getCharset()); config = config.replace(DEFAULT_SECRET, secret); - Files.write(path, config.getBytes()); + Files.write(path, config.getBytes(Config.getCharset())); } private boolean hasError(Form newUserForm) { diff --git a/app/playRepository/BareCommit.java b/app/playRepository/BareCommit.java index e8d9652cb..669fdfcd4 100644 --- a/app/playRepository/BareCommit.java +++ b/app/playRepository/BareCommit.java @@ -26,6 +26,7 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevWalk; import org.eclipse.jgit.treewalk.CanonicalTreeParser; +import utils.Config; import java.io.File; import java.io.IOException; @@ -36,8 +37,9 @@ import static org.eclipse.jgit.lib.Constants.HEAD; import static org.eclipse.jgit.lib.Constants.OBJ_BLOB; -import static utils.LineEnding.*; -import static playRepository.BareRepository.*; +import static playRepository.BareRepository.findFileLineEnding; +import static utils.LineEnding.addEOL; +import static utils.LineEnding.changeLineEnding; public class BareCommit { private PersonIdent personIdent; @@ -138,7 +140,7 @@ private TreeFormatter rebuildExistingTreeWith(String fileName, ObjectId fileObje boolean isInsertedInTree = false; while(!treeParser.eof()){ - String entryName = new String(treeParser.getEntryPathBuffer(), 0, treeParser.getEntryPathLength()); + String entryName = new String(treeParser.getEntryPathBuffer(), 0, treeParser.getEntryPathLength(), Config.getCharset()); String nameForComparison = entryName; if (treeParser.getEntryFileMode() == FileMode.TREE){ @@ -149,12 +151,12 @@ private TreeFormatter rebuildExistingTreeWith(String fileName, ObjectId fileObje isInsertedInTree = true; } else if (nameForComparison.compareTo(fileName) > 0 && isInsertedInTree == false) { formatter.append(fileName, FileMode.REGULAR_FILE, fileObjectId); - formatter.append(entryName.getBytes() + formatter.append(entryName.getBytes(Config.getCharset()) , treeParser.getEntryFileMode() , treeParser.getEntryObjectId()); isInsertedInTree = true; } else { - formatter.append(entryName.getBytes() + formatter.append(entryName.getBytes(Config.getCharset()) , treeParser.getEntryFileMode() , treeParser.getEntryObjectId()); } @@ -174,7 +176,8 @@ private CanonicalTreeParser getCanonicalTreeParser(Repository repository) throws } private ObjectId createGitObjectWithText(String contents) throws IOException { - return objectInserter.insert(OBJ_BLOB, contents.getBytes(), 0, contents.getBytes().length); + byte[] bytes = contents.getBytes(Config.getCharset()); + return objectInserter.insert(OBJ_BLOB, bytes, 0, bytes.length); } private void refUpdate(ObjectId commitId, String refName) throws IOException { diff --git a/app/playRepository/BareRepository.java b/app/playRepository/BareRepository.java index 7e1429254..af4c42eb6 100644 --- a/app/playRepository/BareRepository.java +++ b/app/playRepository/BareRepository.java @@ -36,7 +36,7 @@ import java.io.IOException; import static org.eclipse.jgit.lib.Constants.HEAD; -import static utils.LineEnding.*; +import static utils.LineEnding.findLineEnding; public class BareRepository { /** @@ -58,7 +58,7 @@ public static String readREADME(Project project){ if (loader == null) { return null; } - return new String(loader.getCachedBytes()); + return new String(loader.getCachedBytes(), utils.Config.getCharset()); } public static Repository getRepository(Project project){ @@ -125,7 +125,7 @@ public static EndingType findFileLineEnding(Repository repository, String fileNa if(oldObjectId.equals(ObjectId.zeroId())){ return EndingType.UNDEFINED; } else { - String fileContents = new String(repository.open(oldObjectId).getBytes()); + String fileContents = new String(repository.open(oldObjectId).getBytes(), utils.Config.getCharset()); return findLineEnding(fileContents); } } diff --git a/app/playRepository/SVNRepository.java b/app/playRepository/SVNRepository.java index 5db8b36b1..68bb2aa87 100644 --- a/app/playRepository/SVNRepository.java +++ b/app/playRepository/SVNRepository.java @@ -40,13 +40,11 @@ import org.tmatesoft.svn.core.wc.SVNDiffClient; import org.tmatesoft.svn.core.wc.SVNRevision; import play.libs.Json; +import utils.Config; import utils.FileUtil; import utils.GravatarUtil; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileNotFoundException; -import java.io.IOException; +import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -215,17 +213,17 @@ public void delete() throws Exception { } @Override - public String getPatch(String commitId) throws SVNException { + public String getPatch(String commitId) throws SVNException, UnsupportedEncodingException { long rev = Integer.parseInt(commitId); return getPatch(rev - 1, rev); } @Override - public String getPatch(String revA, String revB) throws SVNException { + public String getPatch(String revA, String revB) throws SVNException, UnsupportedEncodingException { return getPatch(Long.parseLong(revA), Long.parseLong(revB)); } - private String getPatch(long revA, long revB) throws SVNException { + private String getPatch(long revA, long revB) throws SVNException, UnsupportedEncodingException { // Prepare required arguments. SVNURL svnURL = SVNURL.fromFile(new File(getRepoPrefix() + ownerName + "/" + projectName)); @@ -239,7 +237,7 @@ private String getPatch(long revA, long revB) throws SVNException { diffClient.doDiff(svnURL, null, SVNRevision.create(revA), SVNRevision.create(revB), SVNDepth.INFINITY, true, byteArrayOutputStream); - return byteArrayOutputStream.toString(); + return byteArrayOutputStream.toString(Config.getCharset().name()); } @Override diff --git a/app/utils/BasicAuthAction.java b/app/utils/BasicAuthAction.java index 23060e1cc..3e5be91ec 100644 --- a/app/utils/BasicAuthAction.java +++ b/app/utils/BasicAuthAction.java @@ -62,7 +62,7 @@ public static User parseCredentials(String credentials) throws MalformedCredenti String userpassBase64 = credentials.substring(6); byte[] userpassBytes; - userpassBytes = Base64.decodeBase64(userpassBase64.getBytes()); + userpassBytes = Base64.decodeBase64(userpassBase64); // Use ISO-8859-1 only and not others, even if in RFC 2616, Section 2.2 "Basic Rules" allows // TEXT to be encoded according to the rules of RFC 2047. diff --git a/app/utils/Config.java b/app/utils/Config.java index 9db1b4095..6d144cf6f 100644 --- a/app/utils/Config.java +++ b/app/utils/Config.java @@ -26,6 +26,7 @@ import play.mvc.Http; import java.net.*; +import java.nio.charset.Charset; import java.util.Enumeration; public class Config { @@ -271,4 +272,8 @@ private static String getEmail(String prefix) { return user + "@" + config.getString(prefix + ".domain", getHostname()); } } + + public static Charset getCharset() { + return Charset.forName("UTF-8"); + } } diff --git a/app/utils/Markdown.java b/app/utils/Markdown.java index 02634d6ff..069c84ffa 100644 --- a/app/utils/Markdown.java +++ b/app/utils/Markdown.java @@ -34,6 +34,7 @@ import java.io.Reader; import java.net.URI; import java.net.URISyntaxException; +import java.nio.charset.Charset; public class Markdown { @@ -50,15 +51,15 @@ private static ScriptEngine buildEngine() { try { is = Thread.currentThread().getContextClassLoader().getResourceAsStream(XSS_JS_FILE); - reader = new InputStreamReader(is); + reader = new InputStreamReader(is, Config.getCharset()); _engine.eval(reader); is = Thread.currentThread().getContextClassLoader().getResourceAsStream(MARKED_JS_FILE); - reader = new InputStreamReader(is); + reader = new InputStreamReader(is, Config.getCharset()); _engine.eval(reader); is = Thread.currentThread().getContextClassLoader().getResourceAsStream(HIGHLIGHT_JS_FILE); - reader = new InputStreamReader(is); + reader = new InputStreamReader(is, Config.getCharset()); _engine.eval(reader); } catch (Exception ex) { throw new RuntimeException(ex); diff --git a/app/utils/MomentUtil.java b/app/utils/MomentUtil.java index a0c485174..d966029bd 100644 --- a/app/utils/MomentUtil.java +++ b/app/utils/MomentUtil.java @@ -46,7 +46,7 @@ private static ScriptEngine buildEngine() { try { is = Thread.currentThread().getContextClassLoader().getResourceAsStream(MOMENT_JS_FILE); - reader = new InputStreamReader(is); + reader = new InputStreamReader(is, Config.getCharset()); _engine.eval(reader); } catch (Exception ex) { throw new RuntimeException(ex); diff --git a/app/utils/PlayServletResponse.java b/app/utils/PlayServletResponse.java index 44df5faa8..4b89b9abf 100644 --- a/app/utils/PlayServletResponse.java +++ b/app/utils/PlayServletResponse.java @@ -25,6 +25,7 @@ import javax.servlet.*; import javax.servlet.http.*; import java.io.*; +import java.nio.charset.Charset; import java.util.*; public class PlayServletResponse implements HttpServletResponse { @@ -116,7 +117,9 @@ public PlayServletResponse(Response response) throws IOException { this.statusLock = new Object(); this.inputStream = new PipedInputStream(); this.outputStream = new ChunkedOutputStream(new PipedOutputStream(this.inputStream)); - this.pw = new PrintWriter(this.outputStream); + this.pw = new PrintWriter( + new BufferedWriter(new OutputStreamWriter(this.outputStream, Config.getCharset())), + false); } @Override From dc4b3b7edd691da5ef0059ed9d8555edb166a6b3 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Sun, 15 Feb 2015 11:40:52 +0900 Subject: [PATCH 13/20] Cleanup unnecessary code --- app/utils/BasicAuthAction.java | 8 ++------ app/utils/FileUtil.java | 2 -- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/app/utils/BasicAuthAction.java b/app/utils/BasicAuthAction.java index 3e5be91ec..061427113 100644 --- a/app/utils/BasicAuthAction.java +++ b/app/utils/BasicAuthAction.java @@ -23,14 +23,13 @@ import controllers.UserApp; import models.User; import org.apache.commons.codec.binary.Base64; +import play.libs.F.Promise; import play.mvc.Action; import play.mvc.Http; import play.mvc.Http.Context; import play.mvc.Http.Request; import play.mvc.Http.Response; import play.mvc.Result; -import play.mvc.Result; -import play.libs.F.Promise; import java.io.UnsupportedEncodingException; @@ -59,10 +58,7 @@ public static User parseCredentials(String credentials) throws MalformedCredenti return null; } - String userpassBase64 = credentials.substring(6); - byte[] userpassBytes; - - userpassBytes = Base64.decodeBase64(userpassBase64); + byte[] userpassBytes = Base64.decodeBase64(credentials.substring(6)); // Use ISO-8859-1 only and not others, even if in RFC 2616, Section 2.2 "Basic Rules" allows // TEXT to be encoded according to the rules of RFC 2047. diff --git a/app/utils/FileUtil.java b/app/utils/FileUtil.java index 0a1f1cc17..ce6a51544 100644 --- a/app/utils/FileUtil.java +++ b/app/utils/FileUtil.java @@ -32,8 +32,6 @@ public class FileUtil { - public static final int MAX_SIZE_FOR_BINARY_DETECTION = 512; - public static void rm_rf(File file) throws Exception { if(file.isDirectory()){ File[] list = file.listFiles(); From 9ef4fd5328181a4aec6d177de344f807b73a04d8 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Sun, 15 Feb 2015 11:49:59 +0900 Subject: [PATCH 14/20] Update FastHttpDateFormat to fix thread-safe bug Replace the old one with https://github.com/apache/tomcat/blob/9a3837bf4537b9dcee2e6fb3e99d895ba3b3c085/java/org/apache/tomcat/util/http/FastHttpDateFormat.java. to fix thread-safe bugs reported by findbugs. --- app/utils/FastHttpDateFormat.java | 82 +++++++++++++++--------------- app/utils/PlayServletResponse.java | 4 +- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/app/utils/FastHttpDateFormat.java b/app/utils/FastHttpDateFormat.java index 59d353367..f34196a6d 100644 --- a/app/utils/FastHttpDateFormat.java +++ b/app/utils/FastHttpDateFormat.java @@ -14,14 +14,15 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package utils; -import play.*; - -import java.text.*; -import java.util.*; -import java.util.concurrent.*; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import java.util.concurrent.ConcurrentHashMap; /** * Utility class to generate HTTP dates. @@ -34,28 +35,31 @@ public final class FastHttpDateFormat { // -------------------------------------------------------------- Variables - protected static final int CACHE_SIZE = + private static final int CACHE_SIZE = Integer.parseInt(System.getProperty("org.apache.tomcat.util.http.FastHttpDateFormat.CACHE_SIZE", "1000")); /** - * HTTP date format. + * The only date format permitted when generating HTTP headers. */ - protected static final SimpleDateFormat format = - new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); + public static final String RFC1123_DATE = + "EEE, dd MMM yyyy HH:mm:ss zzz"; + + private static final SimpleDateFormat format = + new SimpleDateFormat(RFC1123_DATE, Locale.US); /** * The set of SimpleDateFormat formats to use in getDateHeader(). */ - protected static final SimpleDateFormat formats[] = { - new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US), + private static final SimpleDateFormat formats[] = { + new SimpleDateFormat(RFC1123_DATE, Locale.US), new SimpleDateFormat("EEEEEE, dd-MMM-yy HH:mm:ss zzz", Locale.US), new SimpleDateFormat("EEE MMMM d HH:mm:ss yyyy", Locale.US) }; - protected final static TimeZone gmtZone = TimeZone.getTimeZone("GMT"); + private static final TimeZone gmtZone = TimeZone.getTimeZone("GMT"); /** @@ -75,27 +79,27 @@ public final class FastHttpDateFormat { /** * Instant on which the currentDate object was generated. */ - protected static long currentDateGenerated = 0L; + private static volatile long currentDateGenerated = 0L; /** * Current formatted date. */ - protected static String currentDate = null; + private static String currentDate = null; /** * Formatter cache. */ - protected static final ConcurrentHashMap formatCache = - new ConcurrentHashMap<>(CACHE_SIZE); + private static final ConcurrentHashMap formatCache = + new ConcurrentHashMap<>(CACHE_SIZE); /** * Parser cache. */ - protected static final ConcurrentHashMap parseCache = - new ConcurrentHashMap<>(CACHE_SIZE); + private static final ConcurrentHashMap parseCache = + new ConcurrentHashMap<>(CACHE_SIZE); // --------------------------------------------------------- Public Methods @@ -110,8 +114,8 @@ public static final String getCurrentDate() { if ((now - currentDateGenerated) > 1000) { synchronized (format) { if ((now - currentDateGenerated) > 1000) { - currentDateGenerated = now; currentDate = format.format(new Date(now)); + currentDateGenerated = now; } } } @@ -126,26 +130,24 @@ public static final String getCurrentDate() { public static final String formatDate (long value, DateFormat threadLocalformat) { - Long longValue = value; + Long longValue = new Long(value); String cachedDate = formatCache.get(longValue); - if (cachedDate != null) + if (cachedDate != null) { return cachedDate; + } - String newDate; + String newDate = null; Date dateValue = new Date(value); if (threadLocalformat != null) { newDate = threadLocalformat.format(dateValue); updateFormatCache(longValue, newDate); } else { - synchronized (formatCache) { - synchronized (format) { - newDate = format.format(dateValue); - } - updateFormatCache(longValue, newDate); + synchronized (format) { + newDate = format.format(dateValue); } + updateFormatCache(longValue, newDate); } return newDate; - } @@ -155,27 +157,24 @@ public static final String getCurrentDate() { public static final long parseDate(String value, DateFormat[] threadLocalformats) { - Logger.debug("parseDate " + value); Long cachedDate = parseCache.get(value); - if (cachedDate != null) - return cachedDate; + if (cachedDate != null) { + return cachedDate.longValue(); + } - Long date; + Long date = null; if (threadLocalformats != null) { date = internalParseDate(value, threadLocalformats); updateParseCache(value, date); } else { - synchronized (parseCache) { - date = internalParseDate(value, formats); - updateParseCache(value, date); - } + date = internalParseDate(value, formats); + updateParseCache(value, date); } if (date == null) { return (-1L); - } else { - return date; } + return date.longValue(); } @@ -188,13 +187,14 @@ public static final long parseDate(String value, for (int i = 0; (date == null) && (i < formats.length); i++) { try { date = formats[i].parse(value); - } catch (ParseException ignored) { + } catch (ParseException e) { + // Ignore } } if (date == null) { return null; } - return date.getTime(); + return new Long(date.getTime()); } diff --git a/app/utils/PlayServletResponse.java b/app/utils/PlayServletResponse.java index 4b89b9abf..3a29aa566 100644 --- a/app/utils/PlayServletResponse.java +++ b/app/utils/PlayServletResponse.java @@ -224,7 +224,7 @@ public void addCookie(Cookie cookie) { @Override public void addDateHeader(String name, long date) { - addHeader(name, FastHttpDateFormat.formatDate(date, FastHttpDateFormat.format)); + addHeader(name, FastHttpDateFormat.formatDate(date, null)); } @Override @@ -332,7 +332,7 @@ public void sendRedirect(String location) throws IOException { @Override public void setDateHeader(String name, long date) { - this.response.setHeader(name, FastHttpDateFormat.formatDate(date, FastHttpDateFormat.format)); + this.response.setHeader(name, FastHttpDateFormat.formatDate(date, null)); } @Override From ae9057f2669b609a11000eb7387e093fe6a30e54 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Mon, 23 Feb 2015 18:16:22 +0900 Subject: [PATCH 15/20] Make availableStates immutable --- app/models/Issue.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/app/models/Issue.java b/app/models/Issue.java index 15dae288a..ad18b8918 100644 --- a/app/models/Issue.java +++ b/app/models/Issue.java @@ -35,6 +35,7 @@ import models.resource.Resource; import models.support.SearchCondition; import org.apache.commons.lang3.time.DateUtils; +import org.apache.shiro.util.CollectionUtils; import play.data.Form; import play.data.format.Formats; import play.i18n.Messages; @@ -68,11 +69,8 @@ public class Issue extends AbstractPosting implements LabelOwner { @Formats.DateTime(pattern = "yyyy-MM-dd") public Date dueDate; - public static List availableStates = new ArrayList<>(); - static { - availableStates.add(State.OPEN); - availableStates.add(State.CLOSED); - } + public static final List availableStates = + Collections.unmodifiableList(CollectionUtils.asList(State.OPEN, State.CLOSED)); @ManyToOne public Milestone milestone; From a00946a84051036d82670eef4fef8912d9467470 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Mon, 23 Feb 2015 18:25:41 +0900 Subject: [PATCH 16/20] Make fields final if possible findbugs says, "This static field public but not final, and could be changed by malicious code or by accident from another package. The field could be made final to avoid this vulnerability." --- app/models/IssueComment.java | 2 +- app/models/IssueEvent.java | 2 +- app/models/NotificationEvent.java | 2 +- app/models/NotificationMail.java | 2 +- app/models/PostingComment.java | 2 +- app/models/ProjectTransfer.java | 2 +- app/models/PullRequestCommit.java | 6 +++++- app/models/PullRequestEvent.java | 17 ++++++++--------- app/models/Role.java | 2 +- app/models/Unwatch.java | 2 +- app/models/UserProjectNotification.java | 2 +- app/models/Watch.java | 2 +- app/utils/RouteUtil.java | 2 +- 13 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/models/IssueComment.java b/app/models/IssueComment.java index de73e275d..de952dcbb 100644 --- a/app/models/IssueComment.java +++ b/app/models/IssueComment.java @@ -30,7 +30,7 @@ @Entity public class IssueComment extends Comment { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, IssueComment.class); + public static final Finder find = new Finder<>(Long.class, IssueComment.class); @ManyToOne public Issue issue; diff --git a/app/models/IssueEvent.java b/app/models/IssueEvent.java index 49f34296e..677726803 100644 --- a/app/models/IssueEvent.java +++ b/app/models/IssueEvent.java @@ -55,7 +55,7 @@ public class IssueEvent extends Model implements TimelineItem { private static final int DRAFT_TIME_IN_MILLIS = Configuration.root() .getMilliseconds("application.issue-event.draft-time", 30 * 1000L).intValue(); - public static Finder find = new Finder<>(Long.class, + public static final Finder find = new Finder<>(Long.class, IssueEvent.class); /** diff --git a/app/models/NotificationEvent.java b/app/models/NotificationEvent.java index 0b5ecb06b..c16ffd6c3 100644 --- a/app/models/NotificationEvent.java +++ b/app/models/NotificationEvent.java @@ -66,7 +66,7 @@ public class NotificationEvent extends Model { @Id public Long id; - public static Finder find = new Finder<>(Long.class, NotificationEvent.class); + public static final Finder find = new Finder<>(Long.class, NotificationEvent.class); public String title; diff --git a/app/models/NotificationMail.java b/app/models/NotificationMail.java index 6727c1755..75b83142c 100644 --- a/app/models/NotificationMail.java +++ b/app/models/NotificationMail.java @@ -69,7 +69,7 @@ public class NotificationMail extends Model { @OneToOne public NotificationEvent notificationEvent; - public static Finder find = new Finder<>(Long.class, + public static final Finder find = new Finder<>(Long.class, NotificationMail.class); public static void onStart() { diff --git a/app/models/PostingComment.java b/app/models/PostingComment.java index 734a13ac3..81a9217c4 100644 --- a/app/models/PostingComment.java +++ b/app/models/PostingComment.java @@ -28,7 +28,7 @@ @Entity public class PostingComment extends Comment { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, PostingComment.class); + public static final Finder find = new Finder<>(Long.class, PostingComment.class); @ManyToOne public Posting posting; diff --git a/app/models/ProjectTransfer.java b/app/models/ProjectTransfer.java index 0a1ce8b3d..4707b63f1 100644 --- a/app/models/ProjectTransfer.java +++ b/app/models/ProjectTransfer.java @@ -38,7 +38,7 @@ public class ProjectTransfer extends Model implements ResourceConvertible { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, ProjectTransfer.class); + public static final Finder find = new Finder<>(Long.class, ProjectTransfer.class); @Id public Long id; diff --git a/app/models/PullRequestCommit.java b/app/models/PullRequestCommit.java index 829beb72c..52af97745 100644 --- a/app/models/PullRequestCommit.java +++ b/app/models/PullRequestCommit.java @@ -36,12 +36,16 @@ import playRepository.GitCommit; import utils.JodaDateUtil; +import javax.persistence.*; +import java.util.Date; +import java.util.List; + @Entity public class PullRequestCommit extends Model implements TimelineItem { private static final long serialVersionUID = -4343181252386722689L; - public static Finder find = new Finder<>(Long.class, PullRequestCommit.class); + public static final Finder find = new Finder<>(Long.class, PullRequestCommit.class); @Id public String id; diff --git a/app/models/PullRequestEvent.java b/app/models/PullRequestEvent.java index 3b847e88a..41ed61f76 100644 --- a/app/models/PullRequestEvent.java +++ b/app/models/PullRequestEvent.java @@ -20,26 +20,25 @@ */ package models; -import java.util.ArrayList; -import java.util.Collections; -import java.util.Date; -import java.util.List; - -import javax.persistence.*; - -import org.apache.commons.lang3.StringUtils; import models.enumeration.EventType; import models.enumeration.State; +import org.apache.commons.lang3.StringUtils; import org.joda.time.DateTime; import play.db.ebean.Model; import utils.EventConstants; import utils.JodaDateUtil; +import javax.persistence.*; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Date; +import java.util.List; + @Entity public class PullRequestEvent extends Model implements TimelineItem { private static final long serialVersionUID = 1981361242582594128L; - public static Finder finder = new Finder<>(Long.class, PullRequestEvent.class); + public static final Finder finder = new Finder<>(Long.class, PullRequestEvent.class); @Id public Long id; diff --git a/app/models/Role.java b/app/models/Role.java index b5296cdab..c0cdbf842 100644 --- a/app/models/Role.java +++ b/app/models/Role.java @@ -34,7 +34,7 @@ @Entity public class Role extends Model { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, + public static final Finder find = new Finder<>(Long.class, Role.class); @Id diff --git a/app/models/Unwatch.java b/app/models/Unwatch.java index 2f360598f..9b1ea132e 100644 --- a/app/models/Unwatch.java +++ b/app/models/Unwatch.java @@ -29,7 +29,7 @@ public class Unwatch extends UserAction { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, Unwatch.class); + public static final Finder find = new Finder<>(Long.class, Unwatch.class); public static List findBy(ResourceType resourceType, String resourceId) { return findBy(find, resourceType, resourceId); diff --git a/app/models/UserProjectNotification.java b/app/models/UserProjectNotification.java index 95f3763c3..1199f5766 100644 --- a/app/models/UserProjectNotification.java +++ b/app/models/UserProjectNotification.java @@ -39,7 +39,7 @@ public class UserProjectNotification extends Model { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, UserProjectNotification.class); + public static final Finder find = new Finder<>(Long.class, UserProjectNotification.class); @Id public Long id; diff --git a/app/models/Watch.java b/app/models/Watch.java index 91f36bc4d..6780d80d8 100644 --- a/app/models/Watch.java +++ b/app/models/Watch.java @@ -40,7 +40,7 @@ public class Watch extends UserAction { private static final long serialVersionUID = 1L; - public static Finder find = new Finder<>(Long.class, Watch.class); + public static final Finder find = new Finder<>(Long.class, Watch.class); public static List findBy(ResourceType resourceType, String resourceId) { return findBy(find, resourceType, resourceId); diff --git a/app/utils/RouteUtil.java b/app/utils/RouteUtil.java index 5624ca8aa..dea55958b 100644 --- a/app/utils/RouteUtil.java +++ b/app/utils/RouteUtil.java @@ -34,7 +34,7 @@ import utils.TemplateHelper.DiffRenderer$; public class RouteUtil { - public static DiffRenderer$ diffRenderer = new DiffRenderer$(); + public static final DiffRenderer$ diffRenderer = new DiffRenderer$(); public static String getUrl(ResourceType resourceType, String resourceId) { Long longId = Long.valueOf(resourceId); From 490c1bdeef4534cab8b13430641ebec84dabce23 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Mon, 23 Feb 2015 18:28:06 +0900 Subject: [PATCH 17/20] Implements Cloneable if defines clone() findbugs says, "This class defines a clone() method but the class doesn't implement Cloneable. There are some situations in which this is OK (e.g., you want to control how subclasses can clone themselves), but just make sure that this is what you intended." --- app/controllers/PullRequestApp.java | 2 +- app/models/support/ReviewSearchCondition.java | 13 ++++++++----- app/models/support/SearchCondition.java | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/controllers/PullRequestApp.java b/app/controllers/PullRequestApp.java index 455548452..304514417 100755 --- a/app/controllers/PullRequestApp.java +++ b/app/controllers/PullRequestApp.java @@ -655,7 +655,7 @@ public Result getResult() { } - public static class SearchCondition { + public static class SearchCondition implements Cloneable { public Project project; public String filter; public Long contributorId; diff --git a/app/models/support/ReviewSearchCondition.java b/app/models/support/ReviewSearchCondition.java index 0b379a5f4..ecbb1078f 100644 --- a/app/models/support/ReviewSearchCondition.java +++ b/app/models/support/ReviewSearchCondition.java @@ -20,19 +20,22 @@ */ package models.support; -import models.*; -import java.util.List; -import com.avaje.ebean.Junction; -import models.enumeration.Direction; import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.Junction; import controllers.AbstractPostingApp; +import models.CommentThread; +import models.Project; +import models.ReviewComment; +import models.enumeration.Direction; import org.apache.commons.lang.StringUtils; +import java.util.List; + /** * The class for searching, sorting and filtering in review menu of a project. */ -public class ReviewSearchCondition extends AbstractPostingApp.SearchCondition { +public class ReviewSearchCondition extends AbstractPostingApp.SearchCondition implements Cloneable { public String state; public Long authorId; public Long participantId; diff --git a/app/models/support/SearchCondition.java b/app/models/support/SearchCondition.java index b8f329110..6877c5237 100644 --- a/app/models/support/SearchCondition.java +++ b/app/models/support/SearchCondition.java @@ -36,7 +36,7 @@ import static models.enumeration.ResourceType.ISSUE_COMMENT; import static models.enumeration.ResourceType.ISSUE_POST; -public class SearchCondition extends AbstractPostingApp.SearchCondition { +public class SearchCondition extends AbstractPostingApp.SearchCondition implements Cloneable { public String state; public Boolean commentedCheck; public Long milestoneId; From def5c67ad65aa3b01af059a02399f8cdd2b6a218 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Mon, 23 Feb 2015 18:36:50 +0900 Subject: [PATCH 18/20] Fix unnecessary boxing/unboxing --- app/playRepository/SVNRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/playRepository/SVNRepository.java b/app/playRepository/SVNRepository.java index 68bb2aa87..d590d621f 100644 --- a/app/playRepository/SVNRepository.java +++ b/app/playRepository/SVNRepository.java @@ -344,7 +344,7 @@ public boolean isFile(String path) throws SVNException, IOException { @Override public boolean isFile(String path, String revStr) throws SVNException { - return isFile(path, Long.valueOf(revStr)); + return isFile(path, Long.parseLong(revStr)); } From 00acf647bfc4a0ad291c624616b6cc4a93a4fd27 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Mon, 23 Feb 2015 18:55:06 +0900 Subject: [PATCH 19/20] Remove unused method Findbugs warns the method causes NPE. And I think the method is never used. --- app/controllers/IssueApp.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/app/controllers/IssueApp.java b/app/controllers/IssueApp.java index a8b933214..46f892525 100644 --- a/app/controllers/IssueApp.java +++ b/app/controllers/IssueApp.java @@ -75,9 +75,6 @@ public static Result userIssues(String state, String format, int pageNum) throws Page issues = el.findPagingList(itemsPerPage).getPage(searchCondition.pageNum); switch(format){ - case EXCEL_EXT: - return issuesAsExcel(project, el); - case "pjax": return issuesAsPjax(project, issues, searchCondition); From 9925b83b26d1aa22a1465053d03229611432afa2 Mon Sep 17 00:00:00 2001 From: Yi EungJun Date: Tue, 24 Feb 2015 10:29:40 +0900 Subject: [PATCH 20/20] Organize imports of classes in models package --- app/models/AbstractPosting.java | 4 +- app/models/Assignee.java | 8 ++-- app/models/Attachment.java | 2 +- app/models/AuthInfo.java | 1 - app/models/IssueEvent.java | 4 +- app/models/IssueLabelCategory.java | 2 +- app/models/LabelOwner.java | 4 +- app/models/Milestone.java | 18 +++++---- app/models/NonRangedCodeCommentThread.java | 3 +- app/models/NotificationEvent.java | 7 ++-- app/models/NotificationMail.java | 4 +- app/models/OrganizationUser.java | 7 ++-- app/models/PostingComment.java | 3 +- app/models/Project.java | 5 ++- app/models/ProjectMenuSetting.java | 4 +- app/models/ProjectUser.java | 9 +++-- app/models/PullRequestCommit.java | 12 +----- app/models/PushedBranch.java | 14 +++---- app/models/Role.java | 9 ++--- app/models/Search.java | 5 ++- app/models/SimpleCommentThread.java | 2 - app/models/SiteAdmin.java | 7 ++-- app/models/Unwatch.java | 2 +- app/models/User.java | 22 +++++------ app/models/Watch.java | 2 +- app/models/YobiUpdate.java | 5 +-- app/models/enumeration/EventType.java | 5 ++- app/models/resource/GlobalResource.java | 1 - .../resource/ResourcePersistAdapter.java | 5 +-- app/models/support/FinderTemplate.java | 9 +++-- app/models/support/ModelLock.java | 5 +-- app/models/support/Options.java | 2 +- app/models/support/OrderParam.java | 2 +- app/models/support/OrderParams.java | 5 ++- app/models/support/SearchParam.java | 2 +- app/models/support/SearchParams.java | 5 ++- app/utils/PlayServletRequest.java | 38 +++++-------------- 37 files changed, 110 insertions(+), 134 deletions(-) diff --git a/app/models/AbstractPosting.java b/app/models/AbstractPosting.java index 36f65f90d..d8ae2ae0e 100644 --- a/app/models/AbstractPosting.java +++ b/app/models/AbstractPosting.java @@ -23,11 +23,11 @@ import models.enumeration.ResourceType; import models.resource.Resource; import models.resource.ResourceConvertible; - import org.joda.time.Duration; import play.data.format.Formats; import play.data.validation.Constraints; -import play.db.ebean.*; +import play.db.ebean.Model; +import play.db.ebean.Transactional; import utils.JodaDateUtil; import javax.persistence.*; diff --git a/app/models/Assignee.java b/app/models/Assignee.java index 2e763936a..dfa087598 100644 --- a/app/models/Assignee.java +++ b/app/models/Assignee.java @@ -20,16 +20,14 @@ */ package models; -import java.util.Set; +import play.data.validation.Constraints.Required; +import play.db.ebean.Model; -import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.OneToMany; - -import play.data.validation.Constraints.Required; -import play.db.ebean.Model; +import java.util.Set; @Entity public class Assignee extends Model { diff --git a/app/models/Attachment.java b/app/models/Attachment.java index 1b3519a97..3db042b58 100644 --- a/app/models/Attachment.java +++ b/app/models/Attachment.java @@ -20,7 +20,6 @@ */ package models; -import utils.AttachmentCache; import controllers.AttachmentApp; import models.enumeration.ResourceType; import models.resource.GlobalResource; @@ -33,6 +32,7 @@ import play.db.ebean.Model; import play.libs.Akka; import scala.concurrent.duration.Duration; +import utils.AttachmentCache; import utils.FileUtil; import utils.JodaDateUtil; diff --git a/app/models/AuthInfo.java b/app/models/AuthInfo.java index 52eff9610..c7247f02d 100644 --- a/app/models/AuthInfo.java +++ b/app/models/AuthInfo.java @@ -21,7 +21,6 @@ package models; import play.data.validation.Constraints; -import utils.ReservedWordsValidator; public class AuthInfo { @Constraints.Required diff --git a/app/models/IssueEvent.java b/app/models/IssueEvent.java index 677726803..185053d97 100644 --- a/app/models/IssueEvent.java +++ b/app/models/IssueEvent.java @@ -27,7 +27,9 @@ import play.db.ebean.Model; import javax.persistence.*; -import java.util.*; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; import java.util.regex.Matcher; @Entity diff --git a/app/models/IssueLabelCategory.java b/app/models/IssueLabelCategory.java index 4f72f8fdf..1411f9f21 100644 --- a/app/models/IssueLabelCategory.java +++ b/app/models/IssueLabelCategory.java @@ -21,10 +21,10 @@ package models; import models.enumeration.ResourceType; -import play.db.ebean.Model; import models.resource.Resource; import models.resource.ResourceConvertible; import play.data.validation.Constraints.Required; +import play.db.ebean.Model; import javax.persistence.*; import javax.validation.constraints.Size; diff --git a/app/models/LabelOwner.java b/app/models/LabelOwner.java index f0174d411..ff380c125 100644 --- a/app/models/LabelOwner.java +++ b/app/models/LabelOwner.java @@ -20,10 +20,10 @@ */ package models; -import java.util.Set; - import models.resource.ResourceConvertible; +import java.util.Set; + /** * @see models.resource.ResourceConvertible */ diff --git a/app/models/Milestone.java b/app/models/Milestone.java index 5e014cb64..63e7fb4d6 100644 --- a/app/models/Milestone.java +++ b/app/models/Milestone.java @@ -20,20 +20,24 @@ */ package models; -import models.enumeration.*; +import models.enumeration.Direction; +import models.enumeration.Matching; +import models.enumeration.ResourceType; +import models.enumeration.State; import models.resource.Resource; import models.resource.ResourceConvertible; -import models.support.*; - +import models.support.FinderTemplate; +import models.support.OrderParams; +import models.support.SearchParams; import org.apache.commons.lang3.time.DateUtils; -import play.data.format.*; -import play.data.validation.*; -import play.db.ebean.*; +import play.data.format.Formats; +import play.data.validation.Constraints; +import play.db.ebean.Model; import play.i18n.Messages; import utils.JodaDateUtil; import javax.persistence.*; -import java.text.*; +import java.text.SimpleDateFormat; import java.util.*; @Entity diff --git a/app/models/NonRangedCodeCommentThread.java b/app/models/NonRangedCodeCommentThread.java index 62f56c757..6baa3b564 100644 --- a/app/models/NonRangedCodeCommentThread.java +++ b/app/models/NonRangedCodeCommentThread.java @@ -20,9 +20,10 @@ */ package models; +import org.apache.commons.lang3.StringUtils; + import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import org.apache.commons.lang3.StringUtils; /** * @author Keesun Baik diff --git a/app/models/NotificationEvent.java b/app/models/NotificationEvent.java index c16ffd6c3..4e51f643b 100644 --- a/app/models/NotificationEvent.java +++ b/app/models/NotificationEvent.java @@ -20,7 +20,6 @@ */ package models; -import com.avaje.ebean.RawSql; import com.avaje.ebean.RawSqlBuilder; import controllers.UserApp; import controllers.routes; @@ -42,7 +41,6 @@ import playRepository.*; import scala.concurrent.duration.Duration; import utils.AccessControl; -import utils.Config; import utils.EventConstants; import utils.RouteUtil; @@ -52,7 +50,10 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; -import java.util.*; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/app/models/NotificationMail.java b/app/models/NotificationMail.java index 75b83142c..fcb8c34b6 100644 --- a/app/models/NotificationMail.java +++ b/app/models/NotificationMail.java @@ -20,8 +20,8 @@ */ package models; -import mailbox.EmailAddressWithDetail; import info.schleichardt.play2.mailplugin.Mailer; +import mailbox.EmailAddressWithDetail; import models.enumeration.ResourceType; import models.enumeration.UserState; import models.resource.Resource; @@ -43,11 +43,11 @@ import utils.Markdown; import utils.Url; +import javax.annotation.Nullable; import javax.mail.MessagingException; import javax.mail.Session; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; -import javax.annotation.Nullable; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToOne; diff --git a/app/models/OrganizationUser.java b/app/models/OrganizationUser.java index eb39278cd..248dd826d 100644 --- a/app/models/OrganizationUser.java +++ b/app/models/OrganizationUser.java @@ -20,14 +20,13 @@ */ package models; -import java.util.List; +import models.enumeration.RoleType; +import play.db.ebean.Model; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; - -import models.enumeration.RoleType; -import play.db.ebean.Model; +import java.util.List; @Entity public class OrganizationUser extends Model { diff --git a/app/models/PostingComment.java b/app/models/PostingComment.java index 81a9217c4..4cfe97f92 100644 --- a/app/models/PostingComment.java +++ b/app/models/PostingComment.java @@ -23,7 +23,8 @@ import models.enumeration.ResourceType; import models.resource.Resource; -import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.ManyToOne; @Entity public class PostingComment extends Comment { diff --git a/app/models/Project.java b/app/models/Project.java index c7d07c815..74d55d12c 100644 --- a/app/models/Project.java +++ b/app/models/Project.java @@ -46,7 +46,10 @@ import javax.persistence.*; import javax.servlet.ServletException; import java.io.IOException; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; @Entity public class Project extends Model implements LabelOwner { diff --git a/app/models/ProjectMenuSetting.java b/app/models/ProjectMenuSetting.java index fbcb85e5d..2bffc0d5b 100644 --- a/app/models/ProjectMenuSetting.java +++ b/app/models/ProjectMenuSetting.java @@ -22,7 +22,9 @@ import play.db.ebean.Model; -import javax.persistence.*; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; @Entity public class ProjectMenuSetting extends Model { diff --git a/app/models/ProjectUser.java b/app/models/ProjectUser.java index 6442d9a03..64034708e 100644 --- a/app/models/ProjectUser.java +++ b/app/models/ProjectUser.java @@ -20,14 +20,15 @@ */ package models; -import java.util.*; +import models.enumeration.RoleType; +import play.db.ebean.Model; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; - -import models.enumeration.RoleType; -import play.db.ebean.Model; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; @Entity public class ProjectUser extends Model { diff --git a/app/models/PullRequestCommit.java b/app/models/PullRequestCommit.java index 52af97745..2e12e83a5 100644 --- a/app/models/PullRequestCommit.java +++ b/app/models/PullRequestCommit.java @@ -20,22 +20,12 @@ */ package models; -import java.util.Date; -import java.util.List; - -import javax.annotation.Nonnull; -import javax.persistence.Entity; -import javax.persistence.EnumType; -import javax.persistence.Enumerated; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Transient; - import org.apache.commons.lang3.StringUtils; import play.db.ebean.Model; import playRepository.GitCommit; import utils.JodaDateUtil; +import javax.annotation.Nonnull; import javax.persistence.*; import java.util.Date; import java.util.List; diff --git a/app/models/PushedBranch.java b/app/models/PushedBranch.java index 8c8384a39..df21f4570 100644 --- a/app/models/PushedBranch.java +++ b/app/models/PushedBranch.java @@ -20,19 +20,17 @@ */ package models; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.eclipse.jgit.lib.Constants; +import play.db.ebean.Model; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.ManyToOne; import javax.persistence.Table; - -import org.apache.commons.lang.StringUtils; -import org.eclipse.jgit.lib.Constants; - -import play.db.ebean.Model; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; /** * @author Wansoon Park diff --git a/app/models/Role.java b/app/models/Role.java index c0cdbf842..602f857d8 100644 --- a/app/models/Role.java +++ b/app/models/Role.java @@ -20,16 +20,15 @@ */ package models; -import java.util.ArrayList; -import java.util.List; +import models.enumeration.RoleType; +import play.db.ebean.Model; import javax.persistence.CascadeType; import javax.persistence.Entity; import javax.persistence.Id; import javax.persistence.OneToMany; - -import models.enumeration.RoleType; -import play.db.ebean.Model; +import java.util.ArrayList; +import java.util.List; @Entity public class Role extends Model { diff --git a/app/models/Search.java b/app/models/Search.java index 07f17d238..d7f0ad7fb 100644 --- a/app/models/Search.java +++ b/app/models/Search.java @@ -20,7 +20,10 @@ */ package models; -import com.avaje.ebean.*; +import com.avaje.ebean.Expr; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.Junction; +import com.avaje.ebean.Page; import models.enumeration.Operation; import models.enumeration.ProjectScope; import models.enumeration.UserState; diff --git a/app/models/SimpleCommentThread.java b/app/models/SimpleCommentThread.java index ea971ce68..4cee2f84e 100644 --- a/app/models/SimpleCommentThread.java +++ b/app/models/SimpleCommentThread.java @@ -23,8 +23,6 @@ import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; -import play.db.ebean.Model.Finder; - /** * @author Keesun Baik */ diff --git a/app/models/SiteAdmin.java b/app/models/SiteAdmin.java index e80f37cd4..708bcfec0 100644 --- a/app/models/SiteAdmin.java +++ b/app/models/SiteAdmin.java @@ -20,15 +20,14 @@ */ package models; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.OneToOne; - import controllers.UserApp; import org.apache.shiro.crypto.RandomNumberGenerator; import org.apache.shiro.crypto.SecureRandomNumberGenerator; import play.db.ebean.Model; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.OneToOne; import java.util.Arrays; @Entity diff --git a/app/models/Unwatch.java b/app/models/Unwatch.java index 9b1ea132e..0700f56ef 100644 --- a/app/models/Unwatch.java +++ b/app/models/Unwatch.java @@ -22,7 +22,7 @@ import models.enumeration.ResourceType; -import javax.persistence.*; +import javax.persistence.Entity; import java.util.List; @Entity diff --git a/app/models/User.java b/app/models/User.java index 2220b5d5e..ba12718dc 100644 --- a/app/models/User.java +++ b/app/models/User.java @@ -20,35 +20,33 @@ */ package models; -import java.text.SimpleDateFormat; -import java.util.*; - -import javax.persistence.*; -import javax.persistence.OrderBy; -import javax.persistence.criteria.Expression; - import com.avaje.ebean.*; import controllers.UserApp; -import models.enumeration.*; +import models.enumeration.ResourceType; +import models.enumeration.RoleType; +import models.enumeration.UserState; import models.resource.GlobalResource; import models.resource.Resource; import models.resource.ResourceConvertible; - import models.support.UserComparator; import org.apache.commons.lang3.StringUtils; import org.apache.shiro.crypto.hash.Sha256Hash; import org.apache.shiro.util.ByteSource; import play.data.format.Formats; import play.data.validation.Constraints; -import play.data.validation.Constraints.*; +import play.data.validation.Constraints.Pattern; +import play.data.validation.Constraints.Required; +import play.data.validation.Constraints.ValidateWith; import play.db.ebean.Model; import play.db.ebean.Transactional; -import scala.reflect.internal.Trees; import play.i18n.Messages; import utils.JodaDateUtil; import utils.ReservedWordsValidator; -import static com.avaje.ebean.Expr.eq; +import javax.persistence.*; +import javax.persistence.OrderBy; +import java.text.SimpleDateFormat; +import java.util.*; @Table(name = "n4user") @Entity diff --git a/app/models/Watch.java b/app/models/Watch.java index 6780d80d8..f5d9f566c 100644 --- a/app/models/Watch.java +++ b/app/models/Watch.java @@ -30,7 +30,7 @@ import org.apache.commons.collections.Predicate; import utils.AccessControl; -import javax.persistence.*; +import javax.persistence.Entity; import java.util.ArrayList; import java.util.HashSet; import java.util.List; diff --git a/app/models/YobiUpdate.java b/app/models/YobiUpdate.java index add27323e..0def29835 100644 --- a/app/models/YobiUpdate.java +++ b/app/models/YobiUpdate.java @@ -23,18 +23,15 @@ import com.github.zafarkhaja.semver.Version; import com.github.zafarkhaja.semver.util.UnexpectedElementTypeException; -import com.typesafe.config.*; import org.eclipse.jgit.api.Git; import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.api.errors.InvalidRemoteException; import org.eclipse.jgit.lib.Ref; import play.Configuration; -import play.Logger; import play.libs.Akka; import scala.concurrent.duration.Duration; import utils.Config; -import java.util.*; +import java.util.Collection; import java.util.concurrent.TimeUnit; public class YobiUpdate { diff --git a/app/models/enumeration/EventType.java b/app/models/enumeration/EventType.java index f2acc4a66..16324de7d 100644 --- a/app/models/enumeration/EventType.java +++ b/app/models/enumeration/EventType.java @@ -22,7 +22,10 @@ import play.i18n.Messages; -import java.util.*; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; public enum EventType { diff --git a/app/models/resource/GlobalResource.java b/app/models/resource/GlobalResource.java index 1d13550ec..84f29080e 100644 --- a/app/models/resource/GlobalResource.java +++ b/app/models/resource/GlobalResource.java @@ -21,7 +21,6 @@ package models.resource; import models.Project; -import models.resource.Resource; abstract public class GlobalResource extends Resource { @Override diff --git a/app/models/resource/ResourcePersistAdapter.java b/app/models/resource/ResourcePersistAdapter.java index 7119df445..c81470f80 100644 --- a/app/models/resource/ResourcePersistAdapter.java +++ b/app/models/resource/ResourcePersistAdapter.java @@ -20,14 +20,13 @@ */ package models.resource; -import models.Unwatch; -import models.Watch; - import com.avaje.ebean.EbeanServer; import com.avaje.ebean.Query; import com.avaje.ebean.Transaction; import com.avaje.ebean.event.BeanPersistAdapter; import com.avaje.ebean.event.BeanPersistRequest; +import models.Unwatch; +import models.Watch; /** * @see com.avaje.ebean.event.BeanPersistController diff --git a/app/models/support/FinderTemplate.java b/app/models/support/FinderTemplate.java index 7a9c2a6e1..08a74bdc9 100644 --- a/app/models/support/FinderTemplate.java +++ b/app/models/support/FinderTemplate.java @@ -20,11 +20,12 @@ */ package models.support; -import com.avaje.ebean.*; +import com.avaje.ebean.ExpressionList; +import com.avaje.ebean.Page; +import play.db.ebean.Model; -import play.db.ebean.*; - -import java.util.*; +import java.util.Collection; +import java.util.List; public class FinderTemplate { diff --git a/app/models/support/ModelLock.java b/app/models/support/ModelLock.java index ba2a97854..5eb4062f9 100644 --- a/app/models/support/ModelLock.java +++ b/app/models/support/ModelLock.java @@ -20,12 +20,11 @@ */ package models.support; -import java.util.Map; - import com.google.common.collect.MapMaker; - import play.db.ebean.Model; +import java.util.Map; + public class ModelLock { private final Map locks = new MapMaker().weakValues().makeMap(); diff --git a/app/models/support/Options.java b/app/models/support/Options.java index 0083e1100..2138a64fc 100644 --- a/app/models/support/Options.java +++ b/app/models/support/Options.java @@ -20,7 +20,7 @@ */ package models.support; -import java.util.*; +import java.util.LinkedHashMap; public class Options extends LinkedHashMap { private static final long serialVersionUID = 1L; diff --git a/app/models/support/OrderParam.java b/app/models/support/OrderParam.java index 5c70361eb..3a899b821 100644 --- a/app/models/support/OrderParam.java +++ b/app/models/support/OrderParam.java @@ -20,7 +20,7 @@ */ package models.support; -import models.enumeration.*; +import models.enumeration.Direction; public class OrderParam { diff --git a/app/models/support/OrderParams.java b/app/models/support/OrderParams.java index 54368e1e9..8c631a6eb 100644 --- a/app/models/support/OrderParams.java +++ b/app/models/support/OrderParams.java @@ -20,9 +20,10 @@ */ package models.support; -import models.enumeration.*; +import models.enumeration.Direction; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class OrderParams { diff --git a/app/models/support/SearchParam.java b/app/models/support/SearchParam.java index 8aea41308..612259fd3 100644 --- a/app/models/support/SearchParam.java +++ b/app/models/support/SearchParam.java @@ -20,7 +20,7 @@ */ package models.support; -import models.enumeration.*; +import models.enumeration.Matching; public class SearchParam { diff --git a/app/models/support/SearchParams.java b/app/models/support/SearchParams.java index 25e7c00c4..29fa3a69f 100644 --- a/app/models/support/SearchParams.java +++ b/app/models/support/SearchParams.java @@ -20,9 +20,10 @@ */ package models.support; -import models.enumeration.*; +import models.enumeration.Matching; -import java.util.*; +import java.util.ArrayList; +import java.util.List; public class SearchParams { diff --git a/app/utils/PlayServletRequest.java b/app/utils/PlayServletRequest.java index b0abd5a2a..ce4a51a72 100644 --- a/app/utils/PlayServletRequest.java +++ b/app/utils/PlayServletRequest.java @@ -20,35 +20,6 @@ */ package utils; -import java.io.*; -import java.net.URI; -import java.net.URISyntaxException; -import java.security.Principal; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Map; - -import javax.servlet.AsyncContext; -import javax.servlet.DispatcherType; -import javax.servlet.RequestDispatcher; -import javax.servlet.ServletContext; -import javax.servlet.ServletException; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.Cookie; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import javax.servlet.http.HttpSession; -import javax.servlet.http.Part; - import org.tmatesoft.svn.core.internal.util.SVNEncodingUtil; import play.Play; import play.i18n.Lang; @@ -56,6 +27,15 @@ import play.mvc.Http.RawBuffer; import play.mvc.Http.Request; +import javax.servlet.*; +import javax.servlet.http.*; +import java.io.*; +import java.net.URI; +import java.net.URISyntaxException; +import java.security.Principal; +import java.text.SimpleDateFormat; +import java.util.*; + public class PlayServletRequest implements HttpServletRequest { private String characterEncoding;