Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    FileUpload difference between 6.0p and 4.1p with JPA - why?

    Hi,

    We have ported our big application from SGWT 4.1p to 6.0p. One of the components uses file upload component. The customer filled a bug that when he uploads a file, browser freezes. Depending on the version, it freezes between 10 seconds and couple of minutes.

    Finally I have chased down the issue - in 6.0p the form submission returns the binary contents of the file back in JSON response. Depending on the browser version, parsing of large JSON takes different time.

    The 6.0p response looks like this (pay attention to field called fileContents, containing 500k binary data of the uploaded PNG image):
    Code:
    <HTML>
    <BODY ONLOAD='var results = document.formResults.results.value;if (!(new RegExp(
    "^(\\d{1,3}\\.){3}\\d{1,3}$").test(document.domain))) {
    while (!window.isc && document.domain.indexOf(".") != -1 ) { try { parent.isc; break;} catch (e) {
    document.domain = document.domain.replace(/.*?\./, "");}}}
    parent.isc.Comm.hiddenFrameReply(0,results)'><BR><BR><BR><BR><BR><BR><BR><BR>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <FORM name='formResults'><TEXTAREA readonly name='results'>
    //isc_RPCResponseStart-->[{affectedRows:1,data:{id:7,fileContents_filesize:153038,
    fileContents_filename:"2000px-Deutsches_Bildungssystem-quer.svg.png",name:"TEST",
    fileContents:"�PNG\r\n....<here 500k binary data>...."},
    invalidateCache:false,isDSResponse:true,operationType:"add",queueStatus:0,status:0}]
    //isc_RPCResponseEnd
    </TEXTAREA></FORM>
    </BODY></HTML>
    The same 4.1p response looks like this:
    Code:
    <HTML>
    <BODY ONLOAD='var results = document.formResults.results.value;if (!(new RegExp(
    "^(\\d{1,3}\\.){3}\\d{1,3}$").test(document.domain))) {
    while (!window.isc && document.domain.indexOf(".") != -1 ) { try { parent.isc; break;} catch (e) {
    document.domain = document.domain.replace(/.*?\./, "");}}}
    parent.isc.Comm.hiddenFrameReply(0,results)'><BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <BR><BR><BR><BR><BR><BR><BR><BR><BR>
    <FORM name='formResults'><TEXTAREA readonly name='results'>
    //isc_RPCResponseStart-->[{affectedRows:1,data:{id:8,fileContents_filesize:153038,
    fileContents_filename:"2000px-Deutsches_Bildungssystem-quer.svg.png",name:"Test 4.1"},
    invalidateCache:false,isDSResponse:true,operationType:"add",queueStatus:0,status:0}]
    //isc_RPCResponseEnd</TEXTAREA></FORM>
    </BODY></HTML>
    The Data Source declaration is the following:
    Code:
    <DataSource ID="uploadDS" 
        serverType="jpa" jpaConfig="bgx"
        beanClassName="com.smg.bgx.persistence.test.TestUpload">        
        <fields>
            <field name="id" type="sequence"  hidden="true" primaryKey="true" />
            <field name="name" type="text" title="Name" required="false"  /> 
            <field name="fileContents_filename" type="text" title="Dateiname" required="false" />
            <field name="fileContents_filesize" type="long" title="Dateigroesse" required="false" />
            <field name="fileContents" type="binary" title="Upload Datei" required="false"/>
        </fields>  
    </DataSource>
    The JPA Bean is also simple:
    Code:
    @Entity
    @Table(name="TEST_UPLOAD")
    @NamedQuery(name="TestUpload.findAll", query="SELECT p FROM TestUpload p")
    public class TestUpload implements Serializable, Cloneable {
    
        private static final long serialVersionUID = 1L;
    
        @Id
        @SequenceGenerator(name="TEST_UPLOAD_GENERATOR", sequenceName="TEST_UPLOAD_SEQ", allocationSize=1)
        @GeneratedValue(strategy=GenerationType.SEQUENCE, generator="TEST_UPLOAD_GENERATOR")
        @Column(name="ID")
        private long id;
        
        @Column(name="NAME")
        private String name;
    
        @Column(name="FILE_NAME")
        private String fileContents_filename;
        
        @Column(name="FILE_SIZE")
        private long fileContents_filesize;
    
        @Column(name="FILE_CONTENTS", columnDefinition="BLOB")
        @Lob
        private byte[] fileContents;
    
        //... getters and setters
    }

    So, my question to the community is:

    1. do you see the same behavior?
    2. is it ok?
    3. how can I switch it off?

    #2
    Hi,
    we posted this question 4 weeks ago.
    Does anyone have an idea regarding this problem?
    Thanks!

    Comment


      #3
      This issue is queued to be looked at, however issues filed by customers with Support contracts come first, so your issue hasn't quite risen to the top yet.

      If this is indeed a bug, you should be able to work around it by writing a DMI that takes the default DSResponse and modifies it to remove the binary data, which is not supposed to be there by default.

      Comment


        #4
        Since 5.1 we introduced DataSource.fileContentsField attribute, which beyond its direct purpose affects processing of binary fields in some cases. If it is not set, reserved contents and fileContents field names are causing different behavior of binary fields. So, in order to fix this, you need to rename your binary field or, alternatively, you may declare DataSource.fileContentsField assigning non-existing field name to it just to bypass the default behavior.

        NOTE, that there was a minor bug in this area which is fixed in nightly builds since Jan 31 (today). So, if you would want to use approach of setting DataSource.fileContentsField to non-existing field name, you will need to download the fix first.

        Comment

        Working...
        X