bmarwell commented on code in PR #1968:
URL: https://github.com/apache/maven-mvnd/pull/1968#discussion_r4728613991
##########
common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java:
##########
@@ -220,10 +220,15 @@ private void doUpdate(Runnable updater) {
if (is.available() > 0) {
// a file without the header, as written by an older
mvnd, is reset like a corrupt one
int magic = is.readInt();
- int version = is.readInt();
- if (magic != MAGIC || version != FORMAT_VERSION) {
+ if (magic != MAGIC) {
+ // Old format (no MAGIC) or truncated file: treat
as corrupt.
+ // Do NOT attempt to read the version — the stream
may already be exhausted.
throw new IOException(
- String.format("Unsupported registry header
0x%08X, version %d", magic, version));
+ String.format("Unsupported registry header
0x%08X (old format or corrupt)", magic));
+ }
+ int version = is.readInt();
+ if (version != FORMAT_VERSION) {
+ throw new IOException(String.format("Unsupported
registry version %d", version));
Review Comment:
Here, too. Give the user the file and an action to act on to fix this.
##########
common/src/main/java/org/mvndaemon/mvnd/common/DaemonRegistry.java:
##########
@@ -220,10 +220,15 @@ private void doUpdate(Runnable updater) {
if (is.available() > 0) {
// a file without the header, as written by an older
mvnd, is reset like a corrupt one
int magic = is.readInt();
- int version = is.readInt();
- if (magic != MAGIC || version != FORMAT_VERSION) {
+ if (magic != MAGIC) {
+ // Old format (no MAGIC) or truncated file: treat
as corrupt.
+ // Do NOT attempt to read the version — the stream
may already be exhausted.
throw new IOException(
- String.format("Unsupported registry header
0x%08X, version %d", magic, version));
+ String.format("Unsupported registry header
0x%08X (old format or corrupt)", magic));
Review Comment:
Should output the file and action, so the user can act on it.
--
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]