Skip to content
This repository was archived by the owner on Dec 31, 2024. It is now read-only.

Add EmptyCollectionWriter for MultipartFormContentProcessor #99

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
language: java

jdk:
- oraclejdk8
- oraclejdk9

install:
./mvnw --settings .settings.xml install -DskipTests=true -Dmaven.javadoc.skip=true -Dgpg.skip -B -V
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import feign.codec.Encoder;
import feign.form.multipart.ByteArrayWriter;
import feign.form.multipart.DelegateWriter;
import feign.form.multipart.EmptyCollectionWriter;
import feign.form.multipart.FormDataWriter;
import feign.form.multipart.ManyFilesWriter;
import feign.form.multipart.ManyParametersWriter;
Expand All @@ -48,6 +49,7 @@
/**
*
* @author Artem Labazin
* @author Darren Foong
*/
@FieldDefaults(level = PRIVATE, makeFinal = true)
public class MultipartFormContentProcessor implements ContentProcessor {
Expand All @@ -63,6 +65,7 @@ public class MultipartFormContentProcessor implements ContentProcessor {
*/
public MultipartFormContentProcessor (Encoder delegate) {
writers = new LinkedList<Writer>();
addWriter(new EmptyCollectionWriter());
addWriter(new ByteArrayWriter());
addWriter(new FormDataWriter());
addWriter(new SingleFileWriter());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright 2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package feign.form.multipart;

import java.util.Collection;

import feign.codec.EncodeException;

/**
*
* @author Darren Foong
*/
public class EmptyCollectionWriter implements Writer {

@Override
public boolean isApplicable (Object value) {
return value instanceof Collection && ((Collection) value).isEmpty();
}

@Override
public void write (Output output, String boundary, String key, Object value) throws EncodeException {
// no-op
}
}