Skip to content

Conversation

@reschke
Copy link
Contributor

@reschke reschke commented Oct 2, 2025

No description provided.

@sonarqubecloud
Copy link

sonarqubecloud bot commented Oct 7, 2025

Quality Gate Failed Quality Gate failed

Failed conditions
2 Security Hotspots
69.0% Coverage on New Code (required ≥ 80%)
5.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

Copy link
Contributor

@joerghoh joerghoh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a lot of minor nits, which I think the code could benefit from, mostly when it comes to readability.

+1 for the rest

+ (isolation < Connection.TRANSACTION_READ_COMMITTED ? "lower" : "higher") + " than expected "
+ RDBJDBCTools.isolationLevelToString(Connection.TRANSACTION_READ_COMMITTED)
+ " - check datasource configuration");
LOG.info("Detected transaction isolation level {} is {} than expected {} - check datasource configuration", isolationDiags, isolation < Connection.TRANSACTION_READ_COMMITTED ? "lower" : "higher", RDBJDBCTools.isolationLevelToString(Connection.TRANSACTION_READ_COMMITTED));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mixing the the simple varag parameters with the ternary expression in a single line? I would split it up into multiple lines, so it's more readable.

LOG.info("RDBBlobStore (" + getModuleVersion() + ") instantiated for database " + dbDesc + ", using driver: "
+ driverDesc + ", connecting to: " + dbUrl + (diag.isEmpty() ? "" : (", properties: " + diag.toString()))
+ ", transaction isolation level: " + isolationDiags + ", " + tableInfo);
LOG.info("RDBBlobStore ({}) instantiated for database {}, using driver: {}, connecting to: {}{}, transaction isolation level: {}, {}", getModuleVersion(), dbDesc, driverDesc, dbUrl, diag.isEmpty() ? "" : (", properties: " + diag), isolationDiags, tableInfo);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so above

// the meta is YOUNGER than x
dataStatement.append(" and not exists(select * from " + this.tnMeta + " where " + this.tnMeta + ".ID = "
+ this.tnData + ".ID and LASTMOD > ?)");
dataStatement.append(" and not exists(select * from ").append(this.tnMeta).append(" where ").append(this.tnMeta).append(".ID = ").append(this.tnData).append(".ID and LASTMOD > ?)");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahhh, don't know. That StringBuilder makes it much harder to understand. Personally I would prefer a String.format() approach, but I would be fine, if you just add some newlines into this statement.

long elapsed = System.currentTimeMillis() - ts;
if (elapsed >= 20) {
LOG.debug("Obtaining a new connection from " + this.ds + " took " + elapsed + "ms", new Exception("call stack"));
LOG.debug("Obtaining a new connection from {} took {}ms", this.ds, elapsed, new Exception("call stack"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case this code line is reached and the loglevel is not set to DEBUG, the exception is created (expensive!) but not used. I would guard this debug statement here, so the exception is only created when the log statement is actually printed.

Suggested change
LOG.debug("Obtaining a new connection from {} took {}ms", this.ds, elapsed, new Exception("call stack"));
if (LOG.isDebugEnabled()) {
LOG.debug("Obtaining a new connection from {} took {}ms", this.ds, elapsed, new Exception("call stack"));
}

} catch (SQLException ex) {
LOG.error("Connection class " + c.getClass()
+ " erroneously throws SQLException on setReadOnly(false); not trying again");
LOG.error("Connection class {} erroneously throws SQLException on setReadOnly(false); not trying again", c.getClass());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it make sense to log ex.getMessage() as well to give some more diagnostics?

if (oldDoc == null) {
// document was there but is now gone
LOG.debug("failed to apply update because document is gone in the meantime: " + update.getId(), new Exception("call stack"));
LOG.debug("failed to apply update because document is gone in the meantime: {}", update.getId(), new Exception("call stack"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should guard this log statement also with a check if the DEBUG log is enabled, otherweise we create the exception object without using it.

int[] batchResults = new int[0];

PreparedStatement stmt = connection.prepareStatement("update " + tmd.getName()
String statement = "update " + tmd.getName()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that is very hard to read ... would a String.format(...) help here?

if (maj < dbmax || (maj == dbmax && min < dbmin)) {
result.append(
"Unsupported " + dbname + " version: " + maj + "." + min + ", expected at least " + dbmax + "." + dbmin);
result.append("Unsupported ").append(dbname).append(" version: ").append(maj).append(".").append(min).append(", expected at least ").append(dbmax).append(".").append(dbmin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result.append("Unsupported ").append(dbname).append(" version: ").append(maj).append(".").append(min).append(", expected at least ").append(dbmax).append(".").append(dbmin);
result.append("Unsupported ").append(dbname)
.append(" version: ").append(maj).append(".").append(min)
.append(", expected at least ").append(dbmax).append(".").append(dbmin);

}
result.append("Unsupported " + dbname + " driver version: " + md.getDriverName() + " " + maj + "." + min
+ ", expected at least " + drmax + "." + drmin);
result.append("Unsupported ").append(dbname).append(" driver version: ").append(md.getDriverName()).append(" ").append(maj).append(".").append(min).append(", expected at least ").append(drmax).append(".").append(drmin);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
result.append("Unsupported ").append(dbname).append(" driver version: ").append(md.getDriverName()).append(" ").append(maj).append(".").append(min).append(", expected at least ").append(drmax).append(".").append(drmin);
result.append("Unsupported ").append(dbname)
.append(" driver version: ").append(md.getDriverName())
.append(" ").append(maj).append(".").append(min)
.append(", expected at least ").append(drmax).append(".").append(drmin);

return String.format("Strategy for %s set to %s (via system property %s)", RDBMissingLastRevSeeker.class.getName(),
name, value);
}).get();
.loggingTo(LOG).validateWith(value -> (value == 1 || value == 2)).formatSetMessage((name, value) -> String.format("Strategy for %s set to %s (via system property %s)", RDBMissingLastRevSeeker.class.getName(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard to understand ... maybe some more newlines?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants