diff options
author | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2015-11-10 23:18:22 +0100 |
---|---|---|
committer | Marc R. Hoffmann <hoffmann@mountainminds.com> | 2015-11-10 23:19:46 +0100 |
commit | e175fb33ac0673aca6ac6505bacfbd3d5e61715c (patch) | |
tree | 94e86e330a6e0b8b7e0ba74ca5066d35ada386d5 /org.jacoco.core | |
parent | f4622217085198f3ae42906934026961b29d1111 (diff) | |
parent | 0638deda4eb4907dd8067a524dc915b484d2c22a (diff) | |
download | jacoco-e175fb33ac0673aca6ac6505bacfbd3d5e61715c.tar.gz |
Merge branch 'issue-cleanup-refactoring'
Diffstat (limited to 'org.jacoco.core')
-rw-r--r-- | org.jacoco.core/src/org/jacoco/core/data/ExecutionDataReader.java | 8 | ||||
-rw-r--r-- | org.jacoco.core/src/org/jacoco/core/data/IncompatibleExecDataVersionException.java | 58 |
2 files changed, 63 insertions, 3 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataReader.java b/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataReader.java index 0a8aa41f..b7df3b1d 100644 --- a/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataReader.java +++ b/org.jacoco.core/src/org/jacoco/core/data/ExecutionDataReader.java @@ -74,8 +74,11 @@ public class ExecutionDataReader { * stream has been reached. * @throws IOException * might be thrown by the underlying input stream + * @throws IncompatibleExecDataVersionException + * incompatible data version from different JaCoCo release */ - public boolean read() throws IOException { + public boolean read() throws IOException, + IncompatibleExecDataVersionException { try { byte type; do { @@ -124,8 +127,7 @@ public class ExecutionDataReader { } final char version = in.readChar(); if (version != ExecutionDataWriter.FORMAT_VERSION) { - throw new IOException(format("Incompatible version %x.", - Integer.valueOf(version))); + throw new IncompatibleExecDataVersionException(version); } } diff --git a/org.jacoco.core/src/org/jacoco/core/data/IncompatibleExecDataVersionException.java b/org.jacoco.core/src/org/jacoco/core/data/IncompatibleExecDataVersionException.java new file mode 100644 index 00000000..48c37804 --- /dev/null +++ b/org.jacoco.core/src/org/jacoco/core/data/IncompatibleExecDataVersionException.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2009, 2015 Mountainminds GmbH & Co. KG and Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Marc R. Hoffmann, somechris - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.data; + +import java.io.IOException; + +/** + * Signals that execution data in an incompatible version was tried to read. + */ +public class IncompatibleExecDataVersionException extends IOException { + + private static final long serialVersionUID = 1L; + + private final int actualVersion; + + /** + * Creates a new exception to flag version mismatches in execution data. + * + * @param actualVersion + * version found in the exec data + */ + public IncompatibleExecDataVersionException(final int actualVersion) { + super(String.format("Cannot read execution data version 0x%x. " + + "This version of JaCoCo uses execution data version 0x%x.", + Integer.valueOf(actualVersion), + Integer.valueOf(ExecutionDataWriter.FORMAT_VERSION))); + this.actualVersion = actualVersion; + } + + /** + * Gets the version expected in the execution data which can be read by this + * version of JaCoCo. + * + * @return expected version in execution data + */ + public int getExpectedVersion() { + return ExecutionDataWriter.FORMAT_VERSION; + } + + /** + * Gets the actual version found in the execution data. + * + * @return actual version in execution data + */ + public int getActualVersion() { + return actualVersion; + } + +}
\ No newline at end of file |