Skip to content

Commit bd702cd

Browse files
Apply review feedback
1 parent f499a45 commit bd702cd

File tree

7 files changed

+27
-20
lines changed

7 files changed

+27
-20
lines changed

src/main/java/org/opentripplanner/standalone/OTPMain.java

+14-7
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.opentripplanner.raptor.configure.RaptorConfig;
1414
import org.opentripplanner.routing.graph.SerializedGraphObject;
1515
import org.opentripplanner.standalone.config.CommandLineParameters;
16+
import org.opentripplanner.standalone.config.ConfigModel;
1617
import org.opentripplanner.standalone.configure.ConstructApplication;
1718
import org.opentripplanner.standalone.configure.LoadApplication;
1819
import org.opentripplanner.standalone.server.GrizzlyServer;
@@ -113,13 +114,7 @@ private static void startOTPServer(CommandLineParameters cli) {
113114
var loadApp = new LoadApplication(cli);
114115
var config = loadApp.config();
115116

116-
// optionally check if the config is valid and if not abort the startup process
117-
if (cli.configCheck && config.hasInvalidProperties()) {
118-
throw new OtpAppException(
119-
"Configuration contains invalid properties (see above for details). " +
120-
"Please fix your configuration or remove --configCheck from your OTP CLI parameters."
121-
);
122-
}
117+
detectUnusedConfigParams(cli, config);
123118

124119
// Validate data sources, command line arguments and config before loading and
125120
// processing input data to fail early
@@ -180,6 +175,18 @@ private static void startOTPServer(CommandLineParameters cli) {
180175
}
181176
}
182177

178+
/**
179+
* Optionally, check if the config is valid and if not abort the startup process.
180+
*/
181+
private static void detectUnusedConfigParams(CommandLineParameters cli, ConfigModel config) {
182+
if (cli.configCheck && config.hasIUnknownProperties()) {
183+
throw new OtpAppException(
184+
"Configuration contains invalid properties (see above for details). " +
185+
"Please fix your configuration or remove --configCheck from your OTP CLI parameters."
186+
);
187+
}
188+
}
189+
183190
private static void startOtpWebServer(CommandLineParameters params, ConstructApplication app) {
184191
// Index graph for travel search
185192
app.transitModel().index();

src/main/java/org/opentripplanner/standalone/config/BuildConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ public NodeAdapter asNodeAdapter() {
723723
/**
724724
* Checks if any unknown or invalid properties were encountered while loading the configuration.
725725
*/
726-
public boolean hasInvalidProperties() {
727-
return root.hasInvalidProperties();
726+
public boolean hasUnknownProperties() {
727+
return root.hasUnknownProperties();
728728
}
729729
}

src/main/java/org/opentripplanner/standalone/config/ConfigModel.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,11 @@ public static void initializeOtpFeatures(OtpConfig otpConfig) {
109109
/**
110110
* Checks if any unknown or invalid properties were encountered while loading the configuration.
111111
*/
112-
public boolean hasInvalidProperties() {
112+
public boolean hasIUnknownProperties() {
113113
return (
114-
otpConfig.hasInvalidProperties() ||
115-
buildConfig.hasInvalidProperties() ||
116-
routerConfig.hasInvalidProperties()
114+
otpConfig.hasUnknownProperties() ||
115+
buildConfig.hasUnknownProperties() ||
116+
routerConfig.hasUnknownProperties()
117117
);
118118
}
119119
}

src/main/java/org/opentripplanner/standalone/config/OtpConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public OtpConfig(NodeAdapter nodeAdapter, boolean logUnusedParams) {
7575
/**
7676
* Checks if any unknown or invalid properties were encountered while loading the configuration.
7777
*/
78-
public boolean hasInvalidProperties() {
79-
return root.hasInvalidProperties();
78+
public boolean hasUnknownProperties() {
79+
return root.hasUnknownProperties();
8080
}
8181
}

src/main/java/org/opentripplanner/standalone/config/RouterConfig.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public String toString() {
154154
/**
155155
* Checks if any unknown or invalid properties were encountered while loading the configuration.
156156
*/
157-
public boolean hasInvalidProperties() {
158-
return root.hasInvalidProperties();
157+
public boolean hasUnknownProperties() {
158+
return root.hasUnknownProperties();
159159
}
160160
}

src/main/java/org/opentripplanner/standalone/config/framework/json/NodeAdapter.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public void logAllWarnings(Consumer<String> logger) {
175175
/**
176176
* Checks if any unknown or invalid properties were encountered while loading the configuration.
177177
*/
178-
public boolean hasInvalidProperties() {
178+
public boolean hasUnknownProperties() {
179179
return !unusedParams().isEmpty() || !allWarnings().toList().isEmpty();
180180
}
181181

src/test/java/org/opentripplanner/standalone/config/framework/json/NodeAdapterTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ void invalidProperties() {
569569
// When: Access ONLY parameter 'a', but not 'b'
570570
subject.of("foo").asObject().of("a").asBoolean();
571571

572-
assertTrue(subject.hasInvalidProperties());
572+
assertTrue(subject.hasUnknownProperties());
573573
}
574574

575575
@Test
@@ -581,7 +581,7 @@ void valid() {
581581
object.of("a").asBoolean();
582582
object.of("b").asBoolean();
583583

584-
assertFalse(subject.hasInvalidProperties());
584+
assertFalse(subject.hasUnknownProperties());
585585
}
586586
}
587587

0 commit comments

Comments
 (0)