Skip to content

Commit 897778e

Browse files
committed
Fix NPE in createValue when content type is null
When build-with-parameters plugin calls createValue() during a GET request (to render the parameter form), the request has no content type. This causes req.getFileItem2() to pass null into Pattern.matcher() inside commons-fileupload2's isMultipartRelated(), triggering a NullPointerException. The existing catch block only handles ServletException wrapping FileUploadContentTypeException, so the NPE escapes. Return null early when the content type is null, matching the existing behavior for non-multipart requests.
1 parent 59e1249 commit 897778e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

src/main/java/io/jenkins/plugins/file_parameters/AbstractFileParameterDefinition.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ protected Object readResolve() {
6464
}
6565

6666
@Override public ParameterValue createValue(StaplerRequest2 req) {
67+
if (req.getContentType() == null) {
68+
return null;
69+
}
6770
try {
6871
FileItem src;
6972
try {

0 commit comments

Comments
 (0)