Skip to content

Commit f6f655c

Browse files
committed
Fix compiler warnings
1 parent 675cfed commit f6f655c

13 files changed

Lines changed: 60 additions & 20 deletions

File tree

Model/src/main/java/org/gusdb/wdk/model/ThreadMonitor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void run() {
8888
public void monitorThreads(ThreadMXBean thbean) {
8989

9090
String siteInfo = _config.getAppName() + ", " + ManagementFactory.getRuntimeMXBean().getName();
91-
LOG.info("Thread Monitor started on thread #" + Thread.currentThread().getId() + " - " + siteInfo);
91+
LOG.info("Thread Monitor started on thread #" + Thread.currentThread().threadId() + " - " + siteInfo);
9292
thbean.setThreadContentionMonitoringEnabled(true);
9393

9494
int blockedCycles = 0; // keeps track of amount of time since last report
@@ -119,7 +119,7 @@ public void monitorThreads(ThreadMXBean thbean) {
119119
break;
120120
}
121121
}
122-
LOG.info("Thread monitor stopped on Thread " + Thread.currentThread().getId() + " - " + siteInfo);
122+
LOG.info("Thread monitor stopped on Thread " + Thread.currentThread().threadId() + " - " + siteInfo);
123123
}
124124

125125
private static ThreadState getThreadState(ThreadMXBean thbean) {
@@ -181,7 +181,7 @@ private String getEmailBody(ThreadMXBean thbean, String siteInfo, String stateTe
181181
// get thread infos
182182
long[] ids = new long[blockedThreads.size()];
183183
for (int i = 0; i < ids.length; i++) {
184-
ids[i] = blockedThreads.get(i).getId();
184+
ids[i] = blockedThreads.get(i).threadId();
185185
}
186186
ThreadInfo[] infos = thbean.getThreadInfo(ids);
187187

@@ -194,7 +194,7 @@ private String getEmailBody(ThreadMXBean thbean, String siteInfo, String stateTe
194194
Thread thread = blockedThreads.get(i);
195195
ThreadInfo info = infos[i];
196196
if (info != null) {
197-
buffer.append("<div><div>Thread id=").append(thread.getId())
197+
buffer.append("<div><div>Thread id=").append(thread.threadId())
198198
.append(", name='").append(thread.getName()).append("'</div>\n")
199199
.append("<div>\tblocked count=").append(info.getBlockedCount())
200200
.append(", blocked time=").append(info.getBlockedTime() + "</div>\n")

Model/src/main/java/org/gusdb/wdk/model/Utilities.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
import java.io.IOException;
77
import java.io.InputStream;
88
import java.io.OutputStream;
9+
import java.net.MalformedURLException;
10+
import java.net.URI;
11+
import java.net.URISyntaxException;
12+
import java.net.URL;
913
import java.sql.Clob;
1014
import java.sql.SQLException;
1115
import java.util.Date;
@@ -350,4 +354,12 @@ public static Map<String, Boolean> parseSortList(String sortList) throws WdkMode
350354
return sortingMap;
351355
}
352356

357+
public static URL newURL(String urlString) {
358+
try {
359+
return new URI(urlString).toURL();
360+
}
361+
catch (MalformedURLException | URISyntaxException e) {
362+
throw new RuntimeException("Attempt to use malformed URL: " + urlString, e);
363+
}
364+
}
353365
}

Model/src/main/java/org/gusdb/wdk/model/answer/SummaryViewHandler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public interface SummaryViewHandler {
2727
* @throws WdkModelException if system exception occurs
2828
* @throws WdkUserException if input parameters are invalid
2929
*/
30+
@Deprecated
3031
Map<String, Object> process(RunnableObj<AnswerSpec> answerSpec, Map<String, String[]> parameters, User user)
3132
throws WdkModelException, WdkUserException;
3233

@@ -41,6 +42,7 @@ Map<String, Object> process(RunnableObj<AnswerSpec> answerSpec, Map<String, Stri
4142
* @throws WdkModelException if system exception occurs
4243
* @throws WdkUserException if input parameters are invalid
4344
*/
45+
@Deprecated
4446
String processUpdate(RunnableObj<AnswerSpec> answerSpec, Map<String, String[]> parameters, User user)
4547
throws WdkModelException, WdkUserException;
4648
}

Model/src/main/java/org/gusdb/wdk/model/fix/StepParamExpander.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ public class StepParamExpander extends BaseCLI {
4646

4747
private static final String ARG_THREADED = "threaded";
4848
private static final String ARG_DROP = "dropTablesOnly";
49+
@Deprecated
4950
static final String STEP_PARAMS_TABLE = "step_params";
5051
private static final String UPDATED_STEPS_TABLE = "wdk_updated_steps";
5152

53+
@Deprecated
5254
public static void main(String[] args) {
5355
String cmdName = System.getProperty("cmdName");
5456
StepParamExpander expender = new StepParamExpander(cmdName);
@@ -65,11 +67,13 @@ public static void main(String[] args) {
6567
/**
6668
* @param command
6769
*/
70+
@Deprecated
6871
protected StepParamExpander(String command) {
6972
super((command != null) ? command : "stepParamExpander",
7073
"expand the param clob into its own rows in " + STEP_PARAMS_TABLE + " table");
7174
}
7275

76+
@Deprecated
7377
public void expand(WdkModel wdkModel) throws SQLException, WdkModelException {
7478
String userSchema = wdkModel.getModelConfig().getUserDB().getUserSchema();
7579
DatabaseInstance database = wdkModel.getUserDb();
@@ -171,6 +175,7 @@ private static String getSelectSql(String userSchema, String projectId) {
171175
return getSelectForColumns(userSchema, projectId, "step_id,display_params");
172176
}
173177

178+
@Deprecated
174179
public static String getSelectForColumns(String userSchema, String projectId, String columns) {
175180
String projectIdCondition = (projectId != null ? " AND s.project_id = '" + projectId + "'" : "");
176181
return
@@ -180,6 +185,7 @@ public static String getSelectForColumns(String userSchema, String projectId, St
180185
" AND s.step_id NOT IN (SELECT step_id FROM " + STEP_PARAMS_TABLE + ")";
181186
}
182187

188+
@Deprecated
183189
public static void createParamTable(WdkModel wdkModel) throws SQLException {
184190
DatabaseInstance database = wdkModel.getUserDb();
185191
DataSource dataSource = database.getDataSource();
@@ -224,10 +230,12 @@ public static void createParamTable(WdkModel wdkModel) throws SQLException {
224230
}
225231
}
226232

233+
@Deprecated
227234
public static String getInsertSql() {
228235
return "INSERT INTO " + STEP_PARAMS_TABLE + " (step_id, param_name, param_value) VALUES (?, ?, ?)";
229236
}
230237

238+
@Deprecated
231239
public static Map<String, Set<String>> parseClob(int stepId, String clob)
232240
throws JSONException {
233241
if (clob == null || clob.trim().isEmpty()) {
@@ -243,6 +251,7 @@ public static Map<String, Set<String>> parseClob(int stepId, String clob)
243251
}
244252
}
245253

254+
@Deprecated
246255
public static Map<String, Set<String>> parseDisplayParams(int stepId, JSONObject displayParams) {
247256
return parseParams(stepId, displayParams.has(ParamsAndFiltersDbColumnFormat.KEY_PARAMS) ?
248257
// new displayParams format, fetch params object from params property
@@ -277,6 +286,7 @@ private static Map<String, Set<String>> parseParams(int stepId, JSONObject param
277286
return newValues;
278287
}
279288

289+
@Deprecated
280290
public static String truncateTerm(String term) {
281291
return (term.length() <= 4000 ? term : term.substring(0, 4000));
282292
}
@@ -286,6 +296,7 @@ public static String truncateTerm(String term) {
286296
*
287297
* @see org.gusdb.fgputil.BaseCLI#declareOptions()
288298
*/
299+
@Deprecated
289300
@Override
290301
protected void declareOptions() {
291302
addSingleValueOption(ARG_PROJECT_ID, true, null, "ProjectId, which" +
@@ -299,6 +310,7 @@ protected void declareOptions() {
299310
*
300311
* @see org.gusdb.fgputil.BaseCLI#execute()
301312
*/
313+
@Deprecated
302314
@Override
303315
protected void execute() throws Exception {
304316
String projectId = (String)getOptionValue(ARG_PROJECT_ID);

Model/src/main/java/org/gusdb/wdk/model/fix/StepParamExpanderPlugin.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,15 @@ public class StepParamExpanderPlugin implements TableRowUpdaterPlugin<StepData>
2727

2828
private static final Logger LOG = Logger.getLogger(StepParamExpanderPlugin.class);
2929

30+
@Deprecated
3031
public static class ParamExpanderLoader extends StepDataFactory {
3132

33+
@Deprecated
3234
public ParamExpanderLoader() {
3335
super(true);
3436
}
3537

38+
@Deprecated
3639
@Override
3740
public String getRecordsSql(String schema, String projectId) {
3841
// ignore projectId for now; must select cols from StepDataFactory so we can properly load StepData objs
@@ -42,13 +45,17 @@ public String getRecordsSql(String schema, String projectId) {
4245
}
4346
}
4447

48+
@Deprecated
4549
public static class StepWithParams extends StepData {
4650

4751
private static final int MAX_PARAM_VALUE_LENGTH = 4000;
4852

53+
@Deprecated
4954
public Map<String, Set<String>> params = new HashMap<>();
55+
@Deprecated
5056
public int valueCount;
5157

58+
@Deprecated
5259
public StepWithParams(StepData base) {
5360
super(base);
5461
Map<String, Set<String>> fullParams = StepParamExpander.parseDisplayParams(getStepId().intValue(), getParamFilters());
@@ -118,23 +125,27 @@ public List<String> getTableNamesForBackup(String schema) {
118125

119126
private AtomicInteger _numParams = new AtomicInteger(0);
120127

128+
@Deprecated
121129
@Override
122130
public void configure(WdkModel wdkModel, List<String> additionalArgs) throws Exception {
123131
// no configuration needed
124132
}
125133

134+
@Deprecated
126135
@Override
127136
public TableRowUpdater<StepData> getTableRowUpdater(WdkModel wdkModel) {
128137
return new TableRowUpdater<StepData>(new ParamExpanderLoader(), new ParamValueWriter(), this, wdkModel);
129138
}
130139

140+
@Deprecated
131141
@Override
132142
public RowResult<StepData> processRecord(StepData nextRow) throws Exception {
133143
StepWithParams replacement = new StepWithParams(nextRow);
134144
_numParams.addAndGet(replacement.valueCount);
135145
return new RowResult<StepData>(replacement).setShouldWrite(!replacement.params.isEmpty());
136146
}
137147

148+
@Deprecated
138149
@Override
139150
public void dumpStatistics() {
140151
LOG.info("Wrote " + _numParams.get() + " total param rows to the " + StepParamExpander.STEP_PARAMS_TABLE + " table.");

Model/src/main/java/org/gusdb/wdk/model/test/stress/UrlItem.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
import java.net.MalformedURLException;
66
import java.net.URL;
77

8+
import org.gusdb.wdk.model.Utilities;
9+
810
/**
911
* @author Jerric
1012
*/
@@ -27,11 +29,11 @@ public String getUrlType() {
2729
}
2830

2931
public URL getUrl() throws MalformedURLException {
30-
return new URL( urlPattern );
32+
return Utilities.newURL( urlPattern );
3133
}
3234

3335
public HttpURLConnection getConnection( String cookies ) throws IOException {
34-
URL url = new URL( urlPattern );
36+
URL url = Utilities.newURL( urlPattern );
3537
HttpURLConnection connection = ( HttpURLConnection ) url.openConnection();
3638
connection.setRequestProperty( "User-Agent",
3739
"Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)" );

Model/src/main/java/org/gusdb/wdk/model/user/BasketFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public BasketFactory(WdkModel wdkModel) {
8080
public void addEntireResultToBasket(User user, RunnableObj<AnswerSpec> spec) throws WdkModelException {
8181
AnswerValue answer = AnswerValueFactory.makeAnswer(spec);
8282
int recordCount = answer.getResultSizeFactory().getResultSize();
83-
try (RecordStream records = RecordStreamFactory.getRecordStream(answer, Collections.EMPTY_LIST, Collections.EMPTY_LIST)) {
83+
try (RecordStream records = RecordStreamFactory.getRecordStream(answer, Collections.emptyList(), Collections.emptyList())) {
8484
addToBasket(user, spec.get().getQuestion().get().getRecordClass(), recordCount, records);
8585
}
8686
}

Model/src/main/java/org/gusdb/wdk/model/user/dataset/irods/IrodsUserDatasetSession.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -658,7 +658,7 @@ private JsonUserDataset collectionToDataset(
658658
.orElseGet(Stream::empty)
659659
.map(ICatNode::getName)
660660
.map(s -> new JSONObject().put("name", s))
661-
.reduce(new JSONArray(), JSONArray::put, (a, b) -> a)
661+
.reduce(new JSONArray(), JSONArray::put, (a, _) -> a)
662662
),
663663
metaJson,
664664
dsCol.getPath().resolve(DATAFILES_DIR),

Model/src/main/java/org/gusdb/wdk/model/user/dataset/irods/icat/ICatNode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public abstract class ICatNode {
7575
* metadata value string
7676
*/
7777
public void addMetadata(final String key, final String value) {
78-
metadata.computeIfAbsent(key, __ -> new ArrayList<>()).add(value);
78+
metadata.computeIfAbsent(key, _ -> new ArrayList<>()).add(value);
7979
}
8080

8181
/**

Model/src/main/java/org/gusdb/wdk/model/xml/XmlQuestion.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import org.apache.log4j.Logger;
1616
import org.gusdb.fgputil.xml.TransformException;
1717
import org.gusdb.fgputil.xml.XmlTransformer;
18+
import org.gusdb.wdk.model.Utilities;
1819
import org.gusdb.wdk.model.WdkModel;
1920
import org.gusdb.wdk.model.WdkModelBase;
2021
import org.gusdb.wdk.model.WdkModelException;
@@ -275,7 +276,7 @@ public XmlAnswerValue makeAnswer(int startIndex, int endIndex) throws WdkModelEx
275276
private URL createURL(String data) throws MalformedURLException {
276277
if (data.startsWith("http://") || data.startsWith("ftp://")
277278
|| data.startsWith("https://")) {
278-
return new URL(data);
279+
return Utilities.newURL(data);
279280
} else {
280281
File xmlDataDir = _model.getXmlDataDir();
281282
File xmlDataFile = new File(xmlDataDir, data);

0 commit comments

Comments
 (0)