Skip to content

Commit d6032ae

Browse files
authored
fix: class not found request failure (#357)
* fix: class not found request failure Fix java.lang.NoClassDefFoundError during parseFile resulting in the request failing and causing 500 status codes. We now catch Throwable instead of Exception as this is best effort anyway. Fixes: nvuillam/vscode-groovy-lint#137 * fix: usage table in readme Fix the usage table in the README by escaping pipe characters.
1 parent 05c115f commit d6032ae

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
4848
| -o<br/> --output | String | Output format (txt,json,sarif,html,xml), or path to a file with one of these extensions<br/> Default: `txt`<br/> Examples:<br/> - `"txt"`<br/> - `"json"`<br/> - `"./logs/myLintResults.txt"`<br/> - `"./logs/myLintResults.sarif"`<br/> - `"./logs/myLintResults.html"`<br/> - `"./logs/myLintResults.xml"`<br/>Note: HTML and XML are directly from CodeNarc so using these formats will disable many npm-groovy-lint features |
4949
| -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
5050
| --failon | String | Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Each failure level includes the more critical ones. |
51-
| -c<br/> --config | String | Custom path to [GroovyLint config file](#configuration), or preset config `recommended|recommended-jenkinsfile|all`<br/> Default: Browse current directory to find`.groovylintrc.json|js|yml|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
51+
| -c<br/> --config | String | Custom path to [GroovyLint config file](#configuration), or preset config `recommended\|recommended-jenkinsfile\|all`<br/> Default: Browse current directory to find `.groovylintrc.json\|js\|yml\|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
5252
| --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
5353
| --format | Boolean | Format source code |
5454
| --fix | Boolean | Automatically fix problems when possible<br/> See [Auto-fixable rules](#auto-fixable-rules) |

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Any **question**, **problem** or **enhancement request** ? Ask [**here**](https:
4848
| -o<br/> --output | String | Output format (txt,json,sarif,html,xml), or path to a file with one of these extensions<br/> Default: `txt`<br/> Examples:<br/> - `"txt"`<br/> - `"json"`<br/> - `"./logs/myLintResults.txt"`<br/> - `"./logs/myLintResults.sarif"`<br/> - `"./logs/myLintResults.html"`<br/> - `"./logs/myLintResults.xml"`<br/>Note: HTML and XML are directly from CodeNarc so using these formats will disable many npm-groovy-lint features |
4949
| -l<br/> --loglevel | String | Log level (error,warning or info)<br/>Default: info |
5050
| --failon | String | Defines the error level where CLI will fail (return code = 1). error,warning,info or none. Each failure level includes the more critical ones. |
51-
| -c<br/> --config | String | Custom path to [GroovyLint config file](#configuration), or preset config `recommended|recommended-jenkinsfile|all`<br/> Default: Browse current directory to find`.groovylintrc.json|js|yml|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
51+
| -c<br/> --config | String | Custom path to [GroovyLint config file](#configuration), or preset config `recommended\|recommended-jenkinsfile\|all`<br/> Default: Browse current directory to find `.groovylintrc.json\|js\|yml\|package.json` config file, or default npm-groovy-lint config if not defined.<br/>Note: command-line arguments have priority on config file properties |
5252
| --parse | Boolean | Try to compile the source code and return parse errors (since v5.7.0, default to true, use --no-parse to deactivate) |
5353
| --format | Boolean | Format source code |
5454
| --fix | Boolean | Automatically fix problems when possible<br/> See [Auto-fixable rules](#auto-fixable-rules) |

groovy/src/main/com/nvuillam/Request.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ class Request {
230230
LOGGER.debug('Parse "{}" compilation failed', file.getAbsolutePath())
231231
return ep.getErrorCollector().getErrors()
232232
}
233-
catch (Exception ep) {
233+
catch (Throwable ep) {
234+
// Catch all exceptions to avoid failing the whole request as it's not critical
235+
// and we could get Errors such as java.lang.NoClassDefFoundError.
234236
LOGGER.error('Parse "{}" unexpected exception:', file.getAbsolutePath(), ep)
235237
}
236238

lib/java/CodeNarcServer.jar

-6 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)