reta commented on code in PR #403:
URL: https://github.com/apache/cxf-xjc-utils/pull/403#discussion_r4293824266
##########
cxf-xjc-plugin/src/main/java/org/apache/cxf/maven_plugin/AbstractXSDToJavaMojo.java:
##########
@@ -301,6 +300,30 @@ public void execute() throws MojoExecutionException {
}
}
+ /*
+ * The name of the marker file recording that the given schema location
was processed.
+ * Characters that are invalid in file names are replaced, so a hash of
the location is
+ * added to keep different locations (e.g. "a/b.xsd" and "a_b.xsd") from
sharing a marker.
+ */
+ static String getDoneFileName(String location) {
+ String name = location.replace('?', '_')
+ .replace('&', '_').replace('/', '_').replace('\\', '_')
+ .replace(':', '_').replace('!', '_');
+ if (name.length() > MAX_DONE_FILE_NAME_LENGTH) {
+ name = name.substring(name.length() - MAX_DONE_FILE_NAME_LENGTH);
+ }
+ try {
+ byte[] digest =
MessageDigest.getInstance("SHA-256").digest(location.getBytes(StandardCharsets.UTF_8));
+ StringBuilder hash = new StringBuilder();
+ for (int i = 0; i < 8; i++) {
+ hash.append(String.format("%02x", digest[i]));
+ }
+ return "." + name + "-" + hash + ".DONE";
+ } catch (NoSuchAlgorithmException e) {
+ throw new IllegalStateException(e);
Review Comment:
May be:
```suggestion
throw new MojoExecutionException(e);
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]