Skip to content

Commit 6b4367d

Browse files
author
Suszyński Krzysztof
committed
Merge branch 'release/1.2.0'
2 parents f2049dd + 339b63f commit 6b4367d

19 files changed

+610
-406
lines changed

Diff for: .travis.yml

+24-7
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,28 @@
11
language: java
2-
sudo: false
3-
script: mvn clean install -P '!sonar,ci' --fail-at-end
2+
script: mvn clean install --fail-at-end
43
notifications:
54
email:
65
on_failure: true
7-
jdk:
8-
- openjdk6
9-
- openjdk7
10-
- oraclejdk7
11-
- oraclejdk8
6+
matrix:
7+
include:
8+
- jdk: openjdk6
9+
env: JACOCO=true
10+
- jdk: openjdk7
11+
env: JACOCO=true COVERALLS=true
12+
- jdk: oraclejdk7
13+
env: JACOCO=true
14+
- jdk: oraclejdk8
15+
env: JACOCO=true
16+
- jdk: openjdk7
17+
env: JACOCO=true GDMSESSION=sonar
18+
- jdk: openjdk7
19+
env: JACOCO=true SONAR=publish
20+
script: mvn clean install sonar:sonar --fail-at-end
21+
- jdk: openjdk6
22+
env: JACOCO=false
23+
- jdk: openjdk7
24+
env: JACOCO=false
25+
- jdk: oraclejdk7
26+
env: JACOCO=false
27+
- jdk: oraclejdk8
28+
env: JACOCO=false

Diff for: pom.xml

+19-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
43
<modelVersion>4.0.0</modelVersion>
54
<groupId>pl.wavesoftware</groupId>
65
<artifactId>eid-exceptions</artifactId>
7-
<version>1.1.1-SNAPSHOT</version>
6+
<version>1.2.0</version>
87
<packaging>jar</packaging>
98

109
<name>EID Runtime Exceptions and Utilities</name>
@@ -80,9 +79,12 @@
8079
<sonar.java.source>${java.source.version}</sonar.java.source>
8180
<maven.compiler.source>1.${java.source.version}</maven.compiler.source>
8281
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
82+
<jacoco.version>0.7.6.201602180812</jacoco.version>
8383

84-
<skipTests/>
84+
<skipTests />
8585
<coveralls.skip>${skipTests}</coveralls.skip>
86+
<sonar.skip>${skipTests}</sonar.skip>
87+
<failsafe.rerunFailingTestsCount>2</failsafe.rerunFailingTestsCount>
8688
</properties>
8789

8890
<dependencies>
@@ -129,7 +131,7 @@
129131
<dependency>
130132
<groupId>org.slf4j</groupId>
131133
<artifactId>slf4j-simple</artifactId>
132-
<version>1.7.19</version>
134+
<version>1.7.20</version>
133135
<scope>test</scope>
134136
</dependency>
135137
<dependency>
@@ -169,7 +171,7 @@
169171
<plugin>
170172
<groupId>org.jacoco</groupId>
171173
<artifactId>jacoco-maven-plugin</artifactId>
172-
<version>0.7.6.201602180812</version>
174+
<version>${jacoco.version}</version>
173175
<executions>
174176
<execution>
175177
<id>jacoco-initialize</id>
@@ -319,8 +321,13 @@
319321

320322
<profiles>
321323
<profile>
322-
<id>ci</id>
323-
324+
<id>jacoco</id>
325+
<activation>
326+
<property>
327+
<name>env.JACOCO</name>
328+
<value>true</value>
329+
</property>
330+
</activation>
324331
<build>
325332
<plugins>
326333
<plugin>
@@ -374,13 +381,14 @@
374381
<dependency>
375382
<groupId>org.codehaus.groovy</groupId>
376383
<artifactId>groovy-all</artifactId>
377-
<version>2.4.5</version>
384+
<version>2.4.6</version>
378385
</dependency>
379386
</dependencies>
380387
<configuration>
381388
<defaults>
382389
<sonar.issues.file>${sonar.working.directory}/${sonar.report.export.path}
383390
</sonar.issues.file>
391+
<sonar.skip>${sonar.skip}</sonar.skip>
384392
</defaults>
385393
<source>${project.basedir}/src/test/groovy/verify-sonar-issues.groovy</source>
386394
</configuration>
@@ -399,10 +407,10 @@
399407
</profile>
400408

401409
<profile>
402-
<id>travis</id>
410+
<id>coveralls</id>
403411
<activation>
404412
<property>
405-
<name>env.TRAVIS</name>
413+
<name>env.COVERALLS</name>
406414
<value>true</value>
407415
</property>
408416
</activation>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package pl.wavesoftware.eid;
2+
3+
import javax.annotation.Nonnull;
4+
import javax.annotation.meta.TypeQualifierDefault;
5+
import java.lang.annotation.ElementType;
6+
import java.lang.annotation.Retention;
7+
import java.lang.annotation.RetentionPolicy;
8+
9+
/**
10+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
11+
* @since 2016-03-26
12+
*/
13+
@Nonnull
14+
@TypeQualifierDefault(ElementType.METHOD)
15+
@Retention(RetentionPolicy.RUNTIME)
16+
public @interface ReturnTypesAreNonnullByDefault {
17+
}

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/Eid.java

+15-29
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
*/
1616
package pl.wavesoftware.eid.exceptions;
1717

18-
import javax.annotation.Nonnull;
1918
import javax.annotation.Nullable;
2019
import java.io.Serializable;
2120
import java.util.ArrayList;
@@ -30,7 +29,7 @@
3029
* <p>
3130
* Exception identifier for all Eid Runtime Exceptions.
3231
*
33-
* @author Krzysztof Suszyński <[email protected]>
32+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
3433
*/
3534
public class Eid implements Serializable {
3635

@@ -50,6 +49,8 @@ public class Eid implements Serializable {
5049

5150
private static final int MESSAGE_FORMAT_NUM_SPEC = 2;
5251

52+
private static final String EMPTY_REF = "";
53+
5354
private static String messageFormat = DEFAULT_MESSAGE_FORMAT;
5455

5556
private static UniqIdGenerator uniqIdGenerator = DEFAULT_UNIQ_ID_GENERATOR;
@@ -62,7 +63,7 @@ public class Eid implements Serializable {
6263

6364
private final String ref;
6465

65-
private final Future<String> futureUniqueId;
66+
private String uniqueId;
6667

6768
/**
6869
* Constructor
@@ -71,9 +72,8 @@ public class Eid implements Serializable {
7172
* @param ref an optional reference
7273
*/
7374
public Eid(String id, @Nullable String ref) {
74-
futureUniqueId = new UniqFuture();
7575
this.id = id;
76-
this.ref = ref == null ? "" : ref;
76+
this.ref = ref == null ? EMPTY_REF : ref;
7777
}
7878

7979
/**
@@ -82,7 +82,8 @@ public Eid(String id, @Nullable String ref) {
8282
* @param id the exception id, must be unique developer inserted string, from date
8383
*/
8484
public Eid(String id) {
85-
this(id, null);
85+
this.id = id;
86+
this.ref = EMPTY_REF;
8687
}
8788

8889
/**
@@ -161,26 +162,25 @@ public static String setRefFormat(String refFormat) {
161162
/**
162163
* Makes a log message from this EID object
163164
* <p>
164-
* <p>This method is for convenience of usage of EID in logging. You can use it like this:
165-
* <p>
165+
* This method is for convenience of usage of EID in logging. You can use it like this:
166166
* <pre>
167167
* log.debug(new Eid("20151025:202129").makeLogMessage("A request: %s", request));
168168
* </pre>
169169
* @param logMessageFormat a log message format as accepted by {@link String#format(String, Object...)}
170170
* @param parameters a parameters for logMessageFormat to by passed to {@link String#format(String, Object...)}
171171
* @return a formatted message
172172
*/
173-
public String makeLogMessage(@Nonnull String logMessageFormat, @Nonnull Object... parameters) {
173+
public String makeLogMessage(String logMessageFormat, Object... parameters) {
174174
String message = String.format(logMessageFormat, parameters);
175175
return String.format(getMessageFormat(), this.toString(), message);
176176
}
177177

178178
@Override
179179
public String toString() {
180180
if ("".equals(ref)) {
181-
return String.format(format, id, futureUniqueId.get());
181+
return String.format(format, id, getUniq());
182182
}
183-
return String.format(refFormat, id, ref, futureUniqueId.get());
183+
return String.format(refFormat, id, ref, getUniq());
184184
}
185185

186186
/**
@@ -207,7 +207,10 @@ public String getRef() {
207207
* @return a unique string
208208
*/
209209
public String getUniq() {
210-
return futureUniqueId.get();
210+
if (uniqueId == null) {
211+
uniqueId = uniqIdGenerator.generateUniqId();
212+
}
213+
return uniqueId;
211214
}
212215

213216
private static void validateFormat(String format, int numSpecifiers) {
@@ -241,23 +244,6 @@ public interface UniqIdGenerator {
241244
String generateUniqId();
242245
}
243246

244-
private interface Future<T extends Serializable> extends Serializable {
245-
T get();
246-
}
247-
248-
private static final class UniqFuture implements Future<String> {
249-
private static final long serialVersionUID = 20160325113314L;
250-
private String future;
251-
private UniqFuture() {}
252-
@Override
253-
public String get() {
254-
if (future == null) {
255-
future = uniqIdGenerator.generateUniqId();
256-
}
257-
return future;
258-
}
259-
}
260-
261247
private static final class StdUniqIdGenerator implements UniqIdGenerator {
262248

263249
private static final int BASE36 = 36;

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/EidContainer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
/**
1919
* Indicate that object contains a Eid object
2020
*
21-
* @author Krzysztof Suszyński <[email protected]>
21+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
2222
*/
2323
public interface EidContainer {
2424

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/EidIllegalArgumentException.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @see IllegalArgumentException
2525
* @see EidRuntimeException
26-
* @author Krzysztof Suszyński <[email protected]>
26+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
2727
*/
2828
public class EidIllegalArgumentException extends EidRuntimeException {
2929

@@ -85,7 +85,6 @@ public EidIllegalArgumentException(Eid id, String messageFormat, Object... param
8585
}
8686

8787
/**
88-
* @inheritdoc
8988
* @return {@link IllegalArgumentException} class
9089
*/
9190
@Override

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/EidIllegalStateException.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @see IllegalStateException
2525
* @see EidRuntimeException
26-
* @author Krzysztof Suszyński <[email protected]>
26+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
2727
*/
2828
public class EidIllegalStateException extends EidRuntimeException {
2929

@@ -85,7 +85,6 @@ public EidIllegalStateException(Eid id, String messageFormat, Object... paramete
8585
}
8686

8787
/**
88-
* @inheritdoc
8988
* @return {@link IllegalStateException} class
9089
*/
9190
@Override

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/EidIndexOutOfBoundsException.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @see IndexOutOfBoundsException
2525
* @see EidRuntimeException
26-
* @author Krzysztof Suszyński <[email protected]>
26+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
2727
*/
2828
public class EidIndexOutOfBoundsException extends EidRuntimeException {
2929

@@ -85,7 +85,6 @@ public EidIndexOutOfBoundsException(Eid id, String messageFormat, Object... para
8585
}
8686

8787
/**
88-
* @inheritdoc
8988
* @return {@link IndexOutOfBoundsException} class
9089
*/
9190
@Override

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/EidNullPointerException.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @see NullPointerException
2525
* @see EidRuntimeException
26-
* @author Krzysztof Suszyński <[email protected]>
26+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
2727
*/
2828
public class EidNullPointerException extends EidRuntimeException {
2929

@@ -85,7 +85,6 @@ public EidNullPointerException(Eid id, String messageFormat, Object... parameter
8585
}
8686

8787
/**
88-
* @inheritdoc
8988
* @return {@link NullPointerException} class
9089
*/
9190
@Override

Diff for: src/main/java/pl/wavesoftware/eid/exceptions/EidRuntimeException.java

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
* <p>
3535
* For convenience use {@link pl.wavesoftware.eid.utils.EidPreconditions}
3636
*
37-
* @author Krzysztof Suszyński <[email protected]>
37+
* @author <a href="mailto:[email protected]">Krzysztof Suszynski</a>
3838
*/
3939
public class EidRuntimeException extends RuntimeException implements EidContainer {
4040

@@ -54,13 +54,13 @@ public EidRuntimeException(String eid, String ref) {
5454
}
5555

5656
/**
57-
* Constructs a new runtime exception with the specified cause, a exception Id and detail message of <tt>eid.toString() + " =>
58-
* " + (cause==null ? null : cause.toString())</tt>
59-
* (which typically contains the class and detail message of
60-
* <tt>cause</tt>). This constructor is useful for runtime exceptions that are little more than wrappers for other throwable.
57+
* Constructs a new runtime exception with the specified cause, a exception Id and detail message of
58+
* <code>eid.toString() + " =&gt; " + (cause==null ? null : cause.toString())</code> (which typically contains
59+
* the class and detail message of <code>cause</code>). This constructor is useful for runtime exceptions
60+
* that are little more than wrappers for other throwable.
6161
*
6262
* @param eid exception ID
63-
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <tt>null</tt>
63+
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <code>null</code>
6464
* value is permitted, and indicates that the cause is nonexistent or unknown.)
6565
*/
6666
public EidRuntimeException(String eid, Throwable cause) {
@@ -72,7 +72,7 @@ public EidRuntimeException(String eid, Throwable cause) {
7272
*
7373
* @param eid exception ID
7474
* @param ref the ref code for Eid
75-
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <tt>null</tt> value is
75+
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <code>null</code> value is
7676
* permitted, and indicates that the cause is nonexistent or unknown.)
7777
*/
7878
public EidRuntimeException(String eid, String ref, Throwable cause) {
@@ -92,10 +92,10 @@ public EidRuntimeException(Eid id) {
9292
/**
9393
* Constructs a new runtime exception with the specified Eid object and cause
9494
* <p>
95-
* The detail message is computed as <tt>String.format(Eid.getMessageFormat(), id.toString(), message(cause))</tt>
95+
* The detail message is computed as <code>String.format(Eid.getMessageFormat(), id.toString(), message(cause))</code>
9696
*
9797
* @param id exception ID
98-
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <tt>null</tt> value is
98+
* @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method). (A <code>null</code> value is
9999
* permitted, and indicates that the cause is nonexistent or unknown.)
100100
*/
101101
public EidRuntimeException(Eid id, Throwable cause) {

0 commit comments

Comments
 (0)