Skip to content

Commit

Permalink
Merge pull request #2755 from CrowleyRajapakse/4.6.x
Browse files Browse the repository at this point in the history
Fix failing unique key contraint and intermittent test failure
  • Loading branch information
rmsamitha authored Aug 27, 2020
2 parents 5b5d5d3 + c1782e2 commit 4421410
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ public int addEntry(String path, int parentPathId) throws SQLException, Registry
}
}
} catch (SQLException e) {
if (e instanceof SQLIntegrityConstraintViolationException) {
if (e instanceof SQLIntegrityConstraintViolationException || "23505".equals(e.getSQLState())) {
if (log.isDebugEnabled()) {
log.debug("Failed to insert due to already exist in database : " + path);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,13 @@ public void test4CustomQueryResultsOrderForComments() throws RegistryException {

try {
registry.addComment("/test/comments/r1x", new Comment("commentXX1 on this resource :)"));
Thread.sleep(500);
Thread.sleep(2000);
registry.addComment("/test/comments/r1x", new Comment("commentXX2 on this resource :)"));
Thread.sleep(500);
Thread.sleep(2000);
registry.addComment("/test/comments/r1x", new Comment("commentXX3 on this resource :)"));
Thread.sleep(500);
Thread.sleep(2000);
registry.addComment("/test/comments/r1x", new Comment("a new test comment"));
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RegistryException("Error adding comments to resource", e);
}
Expand Down Expand Up @@ -264,12 +265,18 @@ public void test4CustomQueryResultsOrderForComments() throws RegistryException {
Resource r2 = registry.newResource();
r2.setContent("r2 content");
registry.put("/test/comments/r2", r2);

registry.addComment("/test/comments/r2", new Comment("commentXX1 on this resource :)"));
registry.addComment("/test/comments/r2", new Comment("commentXX2 on this resource :)"));
registry.addComment("/test/comments/r2", new Comment("commentXX3 on this resource :)"));
registry.addComment("/test/comments/r2", new Comment("a new test comment"));

try {
registry.addComment("/test/comments/r2", new Comment("commentXX1 on this resource :)"));
Thread.sleep(2000);
registry.addComment("/test/comments/r2", new Comment("commentXX2 on this resource :)"));
Thread.sleep(2000);
registry.addComment("/test/comments/r2", new Comment("commentXX3 on this resource :)"));
Thread.sleep(2000);
registry.addComment("/test/comments/r2", new Comment("a new test comment"));
Thread.sleep(2000);
} catch (InterruptedException e) {
throw new RegistryException("Sleep Thread Interrupted", e);
}
comQuery = configSystemRegistry.newResource();
sql = "SELECT REG_COMMENT_ID FROM REG_COMMENT C, REG_RESOURCE_COMMENT RC " +
"WHERE C.REG_COMMENT_TEXT LIKE ? AND C.REG_ID=RC.REG_COMMENT_ID " +
Expand Down

0 comments on commit 4421410

Please sign in to comment.