5

Hi I'm getting this error while sending data through a pipe between two parcelFileDescriptors

java.io.IOException: write failed: EPIPE (Broken pipe)
            at libcore.io.IoBridge.write(IoBridge.java:455)
            at java.io.FileOutputStream.write(FileOutputStream.java:187)
            at com.google.common.io.ByteStreams.copy(ByteStreams.java:179)
            at cz.simekadam.android.securedfileprovider.SecuredFileProvider$Pipe.run(SecuredFileProvider.java:161)
Caused by: libcore.io.ErrnoException: write failed: EPIPE (Broken pipe)
            at libcore.io.Posix.writeBytes(Native Method)
            at libcore.io.Posix.write(Posix.java:202)
            at libcore.io.BlockGuardOs.write(BlockGuardOs.java:197)
            at libcore.io.IoBridge.write(IoBridge.java:450)
            at java.io.FileOutputStream.write(FileOutputStream.java:187)
            at com.google.common.io.ByteStreams.copy(ByteStreams.java:179)
            at cz.simekadam.android.securedfileprovider.SecuredFileProvider$Pipe.run(SecuredFileProvider.java:161)    

This is how I'm copying the data.

static class PipeThread extends Thread {
    InputStream input;
    OutputStream out;

    PipeThread(InputStream inputStream, OutputStream out) {
        this.input=inputStream;
        this.out=out;
    }

    @Override
    public void run() {

        try {
            ByteStreams.copy(input, out);
            input.close();
            out.close();
        } catch (IOException e) {
            Log.e(getClass().getSimpleName(),
                "Exception transferring file", e);
        }

    }
}

I've found this questions which says is could has something to do with missing root permissions. I consider this not being my issue because of I'm not writing anything to any folder. The example usecase is sharing an image file from my contentProvider to an app like Skithch..Last not least there is a thing driving me crazy..The process finished successfuly, that means the shared image is opened in skitch without any issues..I'm just seing this in my console and I'm kind of aware of it..I gues it shouldn't be there:)

EDIT: I've tested it further and it seems to only being reproducible when an other app is reading from my ContentProvider. Only then there is the exception being thrown.

Community
  • 1
  • 1
simekadam
  • 7,334
  • 11
  • 56
  • 79
  • 1
    You should `.close()` your resources in a finally block; if `ByteStreams.copy()` fails, you have a resource leak – fge Apr 07 '14 at 08:31
  • Please checkout: http://stackoverflow.com/questions/17615412/android-write-failed-epipe-broken-pipe-error-on-write-file I have edited it. – benchuk Jun 28 '15 at 13:12
  • 1
    Have you managed to fix it? I'm struggling with it right now. – Oliv Jan 21 '16 at 11:32

0 Answers0