Skip to content

Commit

Permalink
Invalid property repeat issue fix (#319)
Browse files Browse the repository at this point in the history
* correcting copyrights

Signed-off-by: Arun Venmany <[email protected]>

* fixing property value diagnostic issue - diagnostic is coming for only last entry if entry is duplicated

Signed-off-by: Arun Venmany <[email protected]>

---------

Signed-off-by: Arun Venmany <[email protected]>
  • Loading branch information
arunvenmany-ibm authored Oct 25, 2024
1 parent dee90d7 commit 56758a4
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public Map<String, PropertiesValidationResult> compute(String text, LibertyTextD
if(!line.isBlank()) {
PropertiesValidationResult validationResult = PropertiesValidationResult.validateServerProperty(line, openedDocument, lineNumber);
if (validationResult.hasErrors()) {
errors.put(line, validationResult);
errors.put(line + "_" + lineNumber, validationResult);
}
}
lineNumber++;
Expand All @@ -70,6 +70,7 @@ public Collection<Diagnostic> convertToLSPDiagnostics(Map<String, PropertiesVali
for (Map.Entry<String, PropertiesValidationResult> errorEntry : propertiesErrors.entrySet()) {
PropertiesValidationResult validationResult = errorEntry.getValue();
String lineContentInError = errorEntry.getKey();
lineContentInError = lineContentInError.contains("_") ? lineContentInError.substring(0, lineContentInError.lastIndexOf("_")) : lineContentInError;
List<Diagnostic> invalidValueDiagnostics = computeInvalidValuesDiagnostic(validationResult, lineContentInError);
lspDiagnostics.addAll(invalidValueDiagnostics);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
public class BootstrapPropertyDiagnosticTest extends AbstractDiagnosticTest {
@Test
public void testBootstrapProperties() throws Exception {
testDiagnostic("bootstrap.properties", 7);
testDiagnostic("bootstrap.properties", 8);
checkDiagnosticsContainsAllRanges(
// Checking invalid value: com.ibm.ws.logging.console.format=DEVd
createRange(0, 34, 38),
Expand All @@ -29,7 +29,9 @@ public void testBootstrapProperties() throws Exception {
// Checking invalid boolean: com.ibm.ws.logging.copy.system.streams=yes
createRange(7, 39, 42),
// Checking invalid package list: org.osgi.framework.bootdelegation=com.ibm.websphere,com.
createRange(8, 34, 56)
createRange(8, 34, 56),
// Checking invalid value: com.ibm.ws.logging.console.format=DEVd
createRange(10, 34, 38)
);
checkDiagnosticsContainsMessages(
"The value `DEVd` is not valid for the property `com.ibm.ws.logging.console.format`.",
Expand All @@ -38,7 +40,8 @@ public void testBootstrapProperties() throws Exception {
"The value `0` is not within the valid range `[1..65535]` for the property `default.http.port`.",
"The value `2147483648` is not within the valid range `[0..2147483647]` for the property `com.ibm.hpel.log.purgeMaxSize`.",
"The value `yes` is not valid for the property `com.ibm.ws.logging.copy.system.streams`.",
"This value must be a comma-delimited list of Java packages."
"This value must be a comma-delimited list of Java packages.",
"The value `DEVd` is not valid for the property `com.ibm.ws.logging.console.format`."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ServerEnvDiagnosticTest extends AbstractDiagnosticTest {
@Test
public void testServerEnv() throws Exception {
// has invalid, case-sensitive, case-insensitive, and negative port integer values.
testDiagnostic("server.env", 5);
testDiagnostic("server.env", 6);
checkDiagnosticsContainsAllRanges(
// Checking invalid value: WLP_LOGGING_CONSOLE_FORMAT=asdf
createRange(0, 27, 31),
Expand All @@ -27,14 +27,17 @@ public void testServerEnv() throws Exception {
// Checking invalid whitespace before equal sign: WLP_DEBUG_REMOTE =n
createRange(4,16,18),
// Checking invalid whitespace after equal sign: WLP_LOGGING_MESSAGE_FORMAT= SIMPLE
createRange(7,26,28)
createRange(7,26,28),
// Checking invalid case-sensitive property: WLP_LOGGING_CONSOLE_SOURCE=messagE
createRange(9, 27, 34)
);
checkDiagnosticsContainsMessages(
"The value `asdf` is not valid for the variable `WLP_LOGGING_CONSOLE_FORMAT`.",
"The value `messagE` is not valid for the variable `WLP_LOGGING_CONSOLE_SOURCE`.",
"The value `-2` is not within the valid range `[1..65535]` for the variable `WLP_DEBUG_ADDRESS`.",
"There should be no whitespace surrounding the equal sign (=).",
"There should be no whitespace surrounding the equal sign (=)."
"There should be no whitespace surrounding the equal sign (=).",
"The value `messagE` is not valid for the variable `WLP_LOGGING_CONSOLE_SOURCE`."
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@ default.http.port=0
com.ibm.hpel.log.purgeMinTime=12h
com.ibm.hpel.log.purgeMaxSize=2147483648
com.ibm.ws.logging.copy.system.streams=yes
org.osgi.framework.bootdelegation=com.ibm.websphere,com.
org.osgi.framework.bootdelegation=com.ibm.websphere,com.
#adding same line again to check diagnostic is coming on both lines
com.ibm.ws.logging.console.format=DEVd
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ WLP_DEBUG_ADDRESS=-2
WLP_DEBUG_REMOTE =n
# adding comment line and blank line to check whether its being ignored

WLP_LOGGING_MESSAGE_FORMAT= SIMPLE
WLP_LOGGING_MESSAGE_FORMAT= SIMPLE
#adding same line again to check diagnostic is coming on both lines
WLP_LOGGING_CONSOLE_SOURCE=messagE

0 comments on commit 56758a4

Please sign in to comment.