Skip to content

Commit

Permalink
Continue on the road towards 2.0.0 and Maven Central compatibility.
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Java 7 minimum requirement, up from 6, as the version of FindBugs and PMD we're using on pull requests doesn't support 6 anymore.
  • Loading branch information
mikaelhg committed May 29, 2015
1 parent aff2917 commit c04b6ec
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 29 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -3,7 +3,6 @@ jdk:
- oraclejdk8
- oraclejdk7
- openjdk7
- openjdk6
install:
- mvn clean package test-compile -DskipTests=true -Dmaven.javadoc.skip=true -B -V
script:
Expand Down
Empty file added exclude-cpd.properties
Empty file.
4 changes: 4 additions & 0 deletions exclude-pmd.properties
@@ -0,0 +1,4 @@
gumi.builders.url.Rfc3986Util=UselessParentheses
gumi.builders.url.Encoder=UselessParentheses
gumi.builders.url.Decoder=UselessParentheses
gumi.builders.UrlBuilder=EmptyCatchBlock
7 changes: 7 additions & 0 deletions findbugs-exclude.xml
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Class name="gumi.builders.UrlBuilder"/>
<Bug code="UrF"/>
</Match>
</FindBugsFilter>
75 changes: 72 additions & 3 deletions pom.xml
Expand Up @@ -17,6 +17,14 @@
</license>
</licenses>

<developers>
<developer>
<name>Mikael Gueck</name>
<email>gumi@iki.fi</email>
<url>http://mikael.io/</url>
</developer>
</developers>

<scm>
<url>https://github.com/mikaelhg/urlbuilder</url>
</scm>
Expand All @@ -34,8 +42,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
Expand All @@ -55,6 +63,12 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.10.3</version>
<configuration>
<quiet>true</quiet>
<!--
<additionalparam>-Xdoclint:none</additionalparam>
-->
</configuration>
<executions>
<execution>
<id>attach-javadocs</id>
Expand Down Expand Up @@ -131,7 +145,6 @@
</dependencies>

<profiles>
<!-- A profile for code coverage analysis in ci environments -->
<profile>
<id>ci</id>
<activation>
Expand Down Expand Up @@ -162,6 +175,62 @@
</plugins>
</build>
</profile>
<profile>
<id>pull-request</id>
<activation>
<property>
<name>env.TRAVIS_PULL_REQUEST</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.1</version>
<configuration>
<effort>Max</effort>
<threshold>Low</threshold>
<xmlOutput>true</xmlOutput>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
</configuration>
<executions>
<execution>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>3.4</version>
<executions>
<execution>
<id>check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<excludeFromFailureFile>exclude-pmd.properties</excludeFromFailureFile>
</configuration>
</execution>
<execution>
<id>cpd-check</id>
<goals>
<goal>cpd-check</goal>
</goals>
<configuration>
<excludeFromFailureFile>exclude-cpd.properties</excludeFromFailureFile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

</project>
4 changes: 2 additions & 2 deletions src/main/java/gumi/builders/url/Decoder.java
Expand Up @@ -118,8 +118,8 @@ protected String urlDecode(final String input, final boolean decodePlusAsSpace)
sb.append(c0);
} else if (len < i + 3) {
// the string will end before we will be able to read a sequence
int endIndex = Math.min(input.length(), i+2);
sb.append(input.substring(i, endIndex));
int endIndex = Math.min(input.length(), i + 2);
sb.append(input.substring(i, endIndex));
i += 3;
} else {
final byte[] bytes = nextDecodeableSequence(input, i);
Expand Down
21 changes: 3 additions & 18 deletions src/main/java/gumi/builders/url/Encoder.java
Expand Up @@ -105,7 +105,7 @@ protected String urlEncode(final String input, final boolean isPath,
for (int i = 0; i < Character.codePointCount(inputChars, 0, inputChars.length); i++) {
final CharBuffer cb;
final int codePoint = Character.codePointAt(inputChars, i);
if (isBmpCodePoint(codePoint)) {
if (Character.isBmpCodePoint(codePoint)) {
final char c = Character.toChars(codePoint)[0];
if ((isPath && isPChar(c) && c != '+')
|| isFragment && isFragmentSafe(c)
Expand All @@ -120,8 +120,8 @@ protected String urlEncode(final String input, final boolean isPath,
}
} else {
cb = CharBuffer.allocate(2);
cb.append(highSurrogate(codePoint));
cb.append(lowSurrogate(codePoint));
cb.append(Character.highSurrogate(codePoint));
cb.append(Character.lowSurrogate(codePoint));
}
cb.rewind();
final ByteBuffer bb = outputEncoding.encode(cb);
Expand All @@ -135,19 +135,4 @@ protected String urlEncode(final String input, final boolean isPath,
return sb.toString();
}

/** Character.highSurrogate is not available in Java 6... **/
protected static char highSurrogate(int codePoint) {
return (char) ((codePoint >>> 10)
+ (Character.MIN_HIGH_SURROGATE - (Character.MIN_SUPPLEMENTARY_CODE_POINT >>> 10)));
}

/** Character.lowSurrogate is not available in Java 6... **/
protected static char lowSurrogate(int codePoint) {
return (char) ((codePoint & 0x3ff) + Character.MIN_LOW_SURROGATE);
}

/** Character.isBmpCodePoint is not available in Java 6... **/
protected static boolean isBmpCodePoint(int codePoint) {
return codePoint >>> 16 == 0;
}
}
10 changes: 5 additions & 5 deletions src/main/java/gumi/builders/url/UrlParameterMultimap.java
Expand Up @@ -26,7 +26,7 @@ public class UrlParameterMultimap implements Map<String, List<String>> {

public static final class Immutable extends UrlParameterMultimap {
public Immutable(final List<Entry<String, String>> data) {
super(Collections.unmodifiableList(new LinkedList<Entry<String, String>>(data)));
super(Collections.unmodifiableList(new LinkedList<>(data)));
}
}

Expand All @@ -45,7 +45,7 @@ public boolean isEmpty() {
}

private static Entry<String, String> newEntry(final String key, final String value) {
return new AbstractMap.SimpleImmutableEntry<String, String>(key, value);
return new AbstractMap.SimpleImmutableEntry<>(key, value);
}

public static UrlParameterMultimap newMultimap() {
Expand All @@ -56,7 +56,7 @@ public static UrlParameterMultimap newMultimap() {
* Make a mutable copy.
*/
public UrlParameterMultimap deepCopy() {
return new UrlParameterMultimap(new LinkedList<Entry<String, String>>(data));
return new UrlParameterMultimap(new LinkedList<>(data));
}

/**
Expand Down Expand Up @@ -199,7 +199,7 @@ public List<Entry<String, String>> flatEntryList() {

@Override
public Set<Entry<String, List<String>>> entrySet() {
final LinkedHashMap<String, List<String>> entries = new LinkedHashMap<String, List<String>>();
final LinkedHashMap<String, List<String>> entries = new LinkedHashMap<>();
for (final Entry<String, String> e : data) {
if (!entries.containsKey(e.getKey())) {
entries.put(e.getKey(), new LinkedList<String>());
Expand All @@ -214,7 +214,7 @@ public Set<Entry<String, List<String>>> entrySet() {

@Override
public Collection<List<String>> values() {
final List<List<String>> ret = new LinkedList<List<String>>();
final List<List<String>> ret = new LinkedList<>();
for (final Entry<String, List<String>> e : this.entrySet()) {
ret.add(e.getValue());
}
Expand Down

0 comments on commit c04b6ec

Please sign in to comment.