Bug 1351785 - non buffered input stream for Config File causes issues with stream reset
Summary: non buffered input stream for Config File causes issues with stream reset
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite 5
Classification: Red Hat
Component: WebUI
Version: 570
Hardware: x86_64
OS: Linux
unspecified
high
Target Milestone: ---
Assignee: Grant Gainey
QA Contact: Radovan Drazny
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-06-30 20:28 UTC by Shannon Hughes
Modified: 2019-12-16 06:01 UTC (History)
5 users (show)

Fixed In Version: spacewalk-java-2.3.8-152-sat
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-08-22 12:24:40 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1645 0 normal SHIPPED_LIVE Satellite 5.7 bug fix update 2016-08-22 16:22:37 UTC

Description Shannon Hughes 2016-06-30 20:28:41 UTC
Description of problem:

When uploading large config files the stream reset causes a stack trace: 

2016-06-30 15:33:07,478 [TP-Processor3] ERROR com.redhat.rhn.domain.config.ConfigurationFactory - IOException while reading config content from input stream!
java.io.IOException: mark/reset not supported
        at java.io.InputStream.reset(InputStream.java:352)
        at com.redhat.rhn.domain.config.ConfigurationFactory.bytesFromStream(ConfigurationFactory.java:856)
        at com.redhat.rhn.domain.config.ConfigurationFactory.createNewContentFromStream(ConfigurationFactory.java:824)
        at com.redhat.rhn.manager.configuration.ConfigFileBuilder.makeNewRevision(ConfigFileBuilder.java:169)
        at com.redhat.rhn.manager.configuration.ConfigFileBuilder.create(ConfigFileBuilder.java:113)
        at com.redhat.rhn.frontend.action.configuration.BaseAddFilesAction.doCreate(BaseAddFilesAction.java:120)
        at com.redhat.rhn.frontend.action.configuration.BaseAddFilesAction.execute(BaseAddFilesAction.java:66)

the above stacktrace occurs in ConfigurationFactory bytesFromStream

          stream.mark(size.intValue());
            do {
                read = stream.read(foo, offset, (foo.length - offset));
                offset += read;
            } while (read > 0 && offset < foo.length);
            stream.reset();


It looks like the following bug commit introduced this for some of the webui config uploads, bz 1091461

This issue looks fixed in spacewalk by wrapping the inputstream with a BufferedInputStream, 

[shughes@dhcp145-192 spacewalk{master}]$ git show c1c4a463d7c497c4b682fcb8190d372831ecf205
commit c1c4a463d7c497c4b682fcb8190d372831ecf205
Author: Bo Maryniuk <bo>
Date:   Tue Nov 11 12:05:36 2014 +0100

    Need to wrap the InputStream in order to support mark/reset so the binary upload won't crash anymore

diff --git a/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java b/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
index d27d6d4..90df700 100644
--- a/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
+++ b/java/code/src/com/redhat/rhn/frontend/action/configuration/ConfigFileForm.java
@@ -35,6 +35,7 @@ import com.redhat.rhn.manager.configuration.file.ConfigFileData;
 import com.redhat.rhn.manager.configuration.file.DirectoryData;
 import com.redhat.rhn.manager.configuration.file.SymlinkData;
 import com.redhat.rhn.manager.configuration.file.TextFileData;
+import java.io.BufferedInputStream;
 
 import org.apache.struts.upload.FormFile;
 
@@ -290,7 +291,7 @@ public class ConfigFileForm extends ScrubbingDynaActionForm {
             if (isUpload()) {
                 FormFile file = (FormFile) get(REV_UPLOAD);
                 try {
-                    data = new BinaryFileData(file.getInputStream(),
+                    data = new BinaryFileData(new BufferedInputStream(file.getInputStream()),
                                                         file.getFileSize());
                 }
                 catch (IOException e) {


Requesting to cherry pick spacewalk c1c4a463d7c497c4b682fcb8190d372831ecf205 into Satellite 570

Comment 4 Grant Gainey 2016-07-01 15:10:46 UTC
spacewalk.github commmits:
c1c4a463d7c497c4b682fcb8190d372831ecf205
5abbdbd186896da3c5abb723e6229f6f0c103b3a

Comment 13 Grant Gainey 2016-08-04 18:36:20 UTC
spacewalk.github:
deaedf150c379dbe0bb96cbc3382f9340e7f4d5c

Comment 20 errata-xmlrpc 2016-08-22 12:24:40 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2016-1645.html


Note You need to log in before you can comment on or make changes to this bug.