Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix failing unique key contraint and intermittent test failure #2755

Merged
merged 1 commit into from
Aug 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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