dhaval
dhaval

Reputation: 2388

Why ItemSkippedException?

I am trying to update content in Google sites and am reading the stream in exception VersionConflictException.

When I check the stream it is all fine and is completely loaded in POST request but then I get following error.

org.apache.commons.fileupload.FileItemStream$ItemSkippedException
at org.apache.commons.fileupload.MultipartStream$ItemInputStream.read(MultipartStream.java:880)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:218)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:258)
at java.io.BufferedInputStream.read(BufferedInputStream.java:317)
at com.google.gdata.data.media.MediaSource$Output.writeTo(MediaSource.java:87)
at com.google.gdata.data.media.MediaBodyPart$MediaSourceDataHandler.writeTo(MediaBodyPart.java:74)
at javax.mail.internet.MimeBodyPart.writeTo(MimeBodyPart.java:452)
at javax.mail.internet.MimeMultipart.writeTo(MimeMultipart.java:157)
at com.google.gdata.wireformats.output.media.MediaMultipartGenerator.generate(MediaMultipartGenerator.java:58)
at com.google.gdata.wireformats.output.media.MediaMultipartGenerator.generate(MediaMultipartGenerator.java:37)
at com.google.gdata.client.Service.writeRequestData(Service.java:1831)
at com.google.gdata.client.media.MediaService.updateMedia(MediaService.java:497)
at com.google.gdata.data.media.MediaEntry.updateMedia(MediaEntry.java:159)
at morefile.UploadApp.updateAttachment(UploadApp.java:136)

Upvotes: 6

Views: 4553

Answers (5)

Rohan Dmello
Rohan Dmello

Reputation: 83

Here is what was happening to me. I was getting this error because I had added

FileItemStream.openStream()

to the "Add Watch" in Intellij Idea, which is why it was throwing me this error. Don't add this to watch while debugging.

Upvotes: -1

user2347987
user2347987

Reputation: 1

I got the same problem. I found it was caused by calling 'Streams.asString( stream)' twice. Reviewing the file upload source code, Streams.asString() will close the stream at the end of its operation, so if you call it again with the same stream, which is InputStream obtained from FileItemStream.openStream() by the way, you will get this exception. Fixed my program, and it works now as I intended!

Upvotes: 0

Nope
Nope

Reputation: 9

I don't want to wake the zombies - this is just for future reference.

This is a basically a bad implementation of the apache-commons-fileupload. Calling hasNext() should NEVER render the result of the last next() call invalid. E.g. you can't do something like this

List collection;
while(hasNext(){
   Object o = next();
   collection.add(o);
}

Because if you access any item in the list it will result in an ItemSkippedException.

Upvotes: 0

Guruprasad GV
Guruprasad GV

Reputation: 986

I used to get this when I used to close the stream during iteration. Don't close the stream and it works fine.

Upvotes: -1

jitter
jitter

Reputation: 54615

FileItemStream.ItemSkippedException

This exception is thrown, if an attempt is made to read data from the InputStream, which has been returned by FileItemStream.openStream(), after Iterator.hasNext() has been invoked on the iterator, which created the FileItemStream.

Upvotes: 8

Related Questions