Skip to content

Commit

Permalink
CLDR-17492 Update spotless to 2.43 and google-java-style 1.22 to supp…
Browse files Browse the repository at this point in the history
…ort Java 21+

See #3757
  • Loading branch information
echeran authored and Squash Bot committed May 28, 2024
1 parent c5140cf commit 2d023d8
Show file tree
Hide file tree
Showing 93 changed files with 216 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
public class CLDRCacheDir {
static final Logger logger = SurveyLog.forClass(CLDRCacheDir.class);
private static final String CACHE_SUBDIR = ".cache";

/** All users of the cache must have an enum entry here */
public enum CacheType {
abstracts("Article excerpts from DBPedia"),
Expand All @@ -27,10 +28,12 @@ public enum CacheType {
public String getDescription() {
return description;
}

/** */
CacheType(String description) {
this.description = description;
}

/**
* Get the 'latest good' date before which a cached item is considered stale. For example,
* if the expiry is 3 days, then the Instant will reflect a date 3 days ago. For some item,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ public File getHomeFile() {

boolean isInitted = false;
private Properties survprops;

/**
* Defaults to SMOKETEST for server
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class BallotBoxXMLSource<T> extends DelegateXMLSource {
static final Logger logger = SurveyLog.forClass(BallotBoxXMLSource.class);

BallotBox<T> ballotBox;

/** original data before any votes */
XMLSource diskData;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public class CookieSession {

public Hashtable<String, Comparable> prefs = new Hashtable<>(); // user prefs
public UserRegistry.User user = null;

/**
* CookieSession.sm was formerly deprecated: "need to refactor anything that uses this." But,
* refactor how?? One possibility: "sm = SurveyMain.getInstance(request)" as in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public class DBUtils {
private static final String JDBC_SURVEYTOOL = ("jdbc/SurveyTool");
private static DataSource datasource = null;
private String connectionUrl = null;

/**
* @Deprecated
*/
Expand Down Expand Up @@ -97,6 +98,7 @@ public String getDBInfo() {
public static int db_number_open = 0;
public static int db_number_used = 0;
private static final int db_UnicodeType = java.sql.Types.BLOB;

/** the StackTracker can track unclosed connections */
private static final StackTracker tracker = DEBUG ? new StackTracker() : null;

Expand Down Expand Up @@ -623,6 +625,7 @@ private static String getDBOpenStack() {
&& !s.getClassName().startsWith("java.")));
return callerElement.toString();
}

/**
* Get an Autocommit Connection. Will be AutoCommit=true
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,19 @@ public class ErrorSubtypeClient {

/** range for the all-subtypes list. This will be written to */
static final String ALL_SUBTYPES_RANGE = "AllSubtypes!A1:A";

/** range for the subtype map. This will be read. Don't count the header. */
static final String SUBTYPE_MAP_RANGE = "SubtypeToURLMap!A2:B";

/** default name of credentials (service key) file */
private static final String SUBTYPE_CREDENTIALS_JSON = "subtype-credentials.json";

/** scopes needed */
private static final List<String> SCOPES = Collections.singletonList(SheetsScopes.SPREADSHEETS);

/** property indicating the full credential path */
private static final String CLDR_SUBTYPE_CREDENTIAL_PATH = "CLDR_SUBTYPE_CREDENTIAL_PATH";

/**
* property indicating the Google Sheet ID of the spreadsheet. Spreadsheet must be shared with
* the service credential for editing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public Collection<String> apply(String xpath) {

protected abstract Collection<String> getCandidates();
}

/** Candidate provider for a single string (not regex) */
abstract static class StringCandidateProvider extends FixedCandidateProvider {
final String pattern;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ private enum MainFormState {
}

MainFormState mainFormState = MainFormState.CLOSED;

/** List of xpaths indicating the types of data being submitted (numbers, currency, etc) */
Set<String> podBases = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public class KeepLoggedInManager {

/** Algorithm to use */
private static final SignatureAlgorithm SIGNATURE_ALGORITHM = SignatureAlgorithm.HS256;

/** Keyfile, just base64 encoded binary data */
private static final String KEYFILE_NAME = KeepLoggedInManager.class.getName() + ".key";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ public class MailSender implements Runnable {

private static final class MailConfig {
final boolean CLDR_SENDMAIL;

/** How many mails to process at a time? 0 = unlimited */
final int CLDR_MAIL_BATCHSIZE;

final int CLDR_MAIL_DELAY_EACH;
final int CLDR_MAIL_DELAY_FIRST;

/** How many seconds to wait between mails in batch processing? 0 = no delay */
final int CLDR_MAIL_DELAY_BATCH_ITEM;

Expand Down
12 changes: 12 additions & 0 deletions tools/cldr-apps/src/main/java/org/unicode/cldr/web/STFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,31 @@ enum VoteLoadingContext {
public final class PerLocaleData implements Comparable<PerLocaleData>, BallotBox<User> {
/** Locale of this PLD */
private final CLDRLocale locale;

/** For readonly locales, there's no DB */
private final boolean readonly;

/** Stamp that tracks if this locale has been modified (by a vote) */
private final MutableStamp stamp;

/** unresolved XMLSource backed by the DB, or null for readonly */
private final BallotBoxXMLSource<User> dataBackedSource;

/** unresolved XMLSource: == dataBackedSource, or for readonly == diskData */
private final XMLSource xmlsource;

/** Unresolved CLDRFile backed by {@link #xmlsource} */
private final CLDRFile file;

/** Resolved CLDRFile backed by {@link #xmlsource} */
private final CLDRFile rFile;

/** List of all XPaths present. Only mutated by makeSureInPathsForFile */
private Set<String> pathsForFile;

/** which XPaths had votes? */
BitSet votesSometimeThisRelease = null;

/** Voting information for each XPath */
private final Map<String, PerXPathData> xpathToData = new HashMap<>();

Expand All @@ -124,6 +133,7 @@ final class PerXPathData {
private final class PerUserData {
/** What is this user voting for? */
String vote;

/** What is this user's override strength? */
Integer override;

Expand Down Expand Up @@ -1250,6 +1260,7 @@ public BallotBox<User> ballotBoxForLocale(CLDRLocale locale) {
/** Config: # of hours before a locale is expired from the cache */
private final int CLDR_LOCALE_CACHE_HOURS =
CLDRConfig.getInstance().getProperty("CLDR_LOCALE_EXPIRE_HOURS", 12);

/** Config: Max # of concurrent locales/sublocales in teh cache */
private final int CLDR_LOCALE_CACHE_MAX =
CLDRConfig.getInstance().getProperty("CLDR_LOCALE_CACHE_MAX", 100);
Expand Down Expand Up @@ -1830,6 +1841,7 @@ public final PathHeader getPathHeader(String xpath) {
public SurveyMenus getSurveyMenus() {
return surveyMenus.get();
}

/**
* Resolving disk file, or null if none.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
description = "parse each of the params as a path or URL to a subtype map and check.")
public class SubtypeToURLMap implements SubtypeToURLProvider {
static final Logger logger = SurveyLog.forClass(SubtypeToURLMap.class);

/**
* Little tool for validating input data.
*
Expand Down Expand Up @@ -283,6 +284,7 @@ public void write(PrintWriter pw) throws IOException {
public List<String> getUrls() {
return urlList;
}

/** get the subtypes that match a certain URL */
public Set<Subtype> getSubtypesForUrl(final String url) {
Set<Subtype> set = new TreeSet<>();
Expand Down Expand Up @@ -453,6 +455,7 @@ static SubtypeToURLMap make() {
}
return map;
}

/**
* The date before which a cache's contents are invalid.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SurveyLog {
public static final Logger forClass(Class<?> clazz) {
return Logger.getLogger(clazz.getName());
}

/**
* Get a Logger class for the specified calling class, with an initial level
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ public String display() {

// ===== Configuration state
private static Phase currentPhase = Phase.VETTING;

/** set by CLDR_PHASE property. * */
private static String oldVersion = "OLDVERSION";

Expand Down Expand Up @@ -354,6 +355,7 @@ private void setInstance() {
}

private static boolean initCalled = false;

/**
* Was init() called on the servlet? This is called very early in server startup,
* but should be noted here.
Expand All @@ -365,6 +367,7 @@ public static boolean wasInitCalled() {
}

private static boolean didTryToStartUp = false;

/**
* Did SurveyMain try to startup? Need to call GET /cldr-apps/survey for this to happen
* if GET has not been called, then we don't have a SurveyMain instance yet and getInstance() will fail.
Expand Down Expand Up @@ -450,6 +453,7 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
}

public static String defaultServletPath = null;

/** IP exclusion list */
public static Hashtable<String, Object> BAD_IPS = new Hashtable<>();

Expand Down Expand Up @@ -1457,6 +1461,7 @@ public static String getCurrev() {
}

static final Pattern HASH_PATTERN = Pattern.compile("^CLDR_([A-Z]+)_HASH$");

/**
* Get the current source revision
*
Expand Down Expand Up @@ -3332,6 +3337,7 @@ public static void markBusted(String what, Throwable t, String stack) {
}

private static long shortN = 0;

/** Only used by about.jsp to know whether it's safe to call DBUtils.getInstance() */
public static boolean isDbSetup = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private synchronized void notify(User u) {
}

private static final java.util.logging.Logger logger = SurveyLog.forClass(UserRegistry.class);

// user levels

/** Administrator */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,19 @@ public String getMessage() {
public void setMessage(String message) {
this.message = message;
}

/** Description of the error */
@Schema(description = "Error message")
public String message;

/** identifies this as an error */
@Schema(description = "Always set to true, identifies this as an error.")
public final boolean err = true;

/** Optional error code */
@Schema(description = "Error code if present")
public ErrorCode code;

/**
* Convenience function: return STError("something").build() => 500
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,7 @@ public static Response handleVote(
return new STError(se).build();
}
}

/**
* this function is the implementation of handleVote() but does not use any jax-rs, for unit
* tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ private String votedToString(boolean didVote) {

@Test
public void TestBasicVote()
throws SQLException, IOException, InvalidXPathException, VoteNotAcceptedException,
throws SQLException,
IOException,
InvalidXPathException,
VoteNotAcceptedException,
LogoutException {
STFactory fac = getFactory();

Expand Down Expand Up @@ -354,7 +357,10 @@ public void TestDenyVote() throws SQLException, IOException {

@Test
public void TestSparseVote()
throws SQLException, IOException, InvalidXPathException, SurveyException,
throws SQLException,
IOException,
InvalidXPathException,
SurveyException,
LogoutException {
STFactory fac = getFactory();

Expand Down Expand Up @@ -503,7 +509,10 @@ public static BufferedReader getUTF8Data(String name) throws java.io.IOException

@Test
public void TestVettingWithNonDistinguishing()
throws SQLException, IOException, InvalidXPathException, SurveyException,
throws SQLException,
IOException,
InvalidXPathException,
SurveyException,
LogoutException {
if (TestAll.skipIfNoDb()) return;
STFactory fac = getFactory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ protected void handleException(Throwable e) {
errln(sourceLocation(ex) + ex.toString() + '\n' + msg);
}
}

// use this instead of new random so we get a consistent seed
// for our tests
protected Random createRandom() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@ public static final BufferedReader getDataReader(String name) throws IOException
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'
};

/**
* Return true if the character is NOT printable ASCII. The tab, newline and linefeed characters
* are considered unprintable.
*/
public static boolean isUnprintable(int c) {
return !(c >= 0x20 && c <= 0x7E);
}

/**
* Escape unprintable characters using <backslash>uxxxx notation for U+0000 to U+FFFF and
* <backslash>Uxxxxxxxx for U+10000 and above. If the character is printable ASCII, then do
Expand Down
Loading

0 comments on commit 2d023d8

Please sign in to comment.