Skip to content

Commit

Permalink
Build: Fix minor error-prone warnings (apache#6629)
Browse files Browse the repository at this point in the history
* Build: Fix minor error-prone warnings

* Enforce StringSplitter to avoid future warnings
  • Loading branch information
ajantha-bhat authored Jan 23, 2023
1 parent 4491e7d commit 881be5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 2 additions & 0 deletions baseline.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ subprojects {
// Enforce hashCode over hash
'-Xep:ObjectsHashCodeUnnecessaryVarargs:ERROR',
'-Xep:PreferSafeLogger:OFF',
// Enforce safe string splitting
'-Xep:StringSplitter:ERROR',
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,14 +329,14 @@ static Long expiresAtMillis(String token) {
return null;
}

String[] parts = token.split("\\.");
if (parts.length != 3) {
List<String> parts = Splitter.on('.').splitToList(token);
if (parts.size() != 3) {
return null;
}

JsonNode node;
try {
node = JsonUtil.mapper().readTree(Base64.getUrlDecoder().decode(parts[1]));
node = JsonUtil.mapper().readTree(Base64.getUrlDecoder().decode(parts.get(1)));
} catch (IOException e) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
*/
package org.apache.iceberg.hive;

import java.util.List;
import org.apache.hive.common.util.HiveVersionInfo;
import org.apache.iceberg.relocated.com.google.common.base.Splitter;

public enum HiveVersion {
HIVE_4(4),
Expand All @@ -44,16 +46,16 @@ public static boolean min(HiveVersion other) {

private static HiveVersion calculate() {
String version = HiveVersionInfo.getShortVersion();
String[] versions = version.split("\\.");
switch (versions[0]) {
List<String> versions = Splitter.on('.').splitToList(version);
switch (versions.get(0)) {
case "4":
return HIVE_4;
case "3":
return HIVE_3;
case "2":
return HIVE_2;
case "1":
if (versions[1].equals("2")) {
if (versions.get(1).equals("2")) {
return HIVE_1_2;
} else {
return NOT_SUPPORTED;
Expand Down

0 comments on commit 881be5e

Please sign in to comment.