Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1, 1.2, 2.0, 2.1
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      FacesEvent (and its derivative objects) are marked as serializable, yet they are not if a phaseId is provided. The following test class:

      public class Test
      {
      public static void main(String[] argv)
      {
      ActionEvent event = new ActionEvent(new UIOutput());
      event.setPhaseId(PhaseId.APPLY_REQUEST_VALUES);

      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream oout;
      try

      { oout = new ObjectOutputStream(out); oout.writeObject(event); }

      catch (IOException e)

      { e.printStackTrace(); }

      }
      }

      Yields the following error:

      java.io.NotSerializableException: javax.faces.event.PhaseId
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1165)
      at
      java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1535)
      at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1496)
      at
      java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1413)
      at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1159)
      at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:329)
      at test.Test.main(Test.java:31)

      This is because PhaseId is not serializable. Regardless of PhaseId's ability to be serialized, FacesEvent must honor the serializable contract and be able to be serializable.

        Activity

        Hide
        Ed Burns added a comment -

        Unfortunately, because PhaseId is a javax.faces class, we cannot change its signature without revising the JSF specification. We will tackle this in 2.3.

        Show
        Ed Burns added a comment - Unfortunately, because PhaseId is a javax.faces class, we cannot change its signature without revising the JSF specification. We will tackle this in 2.3.
        Hide
        Ed Burns added a comment -

        I may be able to come up with a workaround to make this work in the meantime.

        Show
        Ed Burns added a comment - I may be able to come up with a workaround to make this work in the meantime.
        Hide
        Hanspeter Duennenberger added a comment -

        Would below change affect signature as well?
        As workaround this would use the PhaseId ordinal as serialized value in FacesEvent:

        Index: jsf-api/src/main/java/javax/faces/event/FacesEvent.java
        ===================================================================
        --- jsf-api/src/main/java/javax/faces/event/FacesEvent.java	(revision 13233)
        +++ jsf-api/src/main/java/javax/faces/event/FacesEvent.java	(working copy)
        @@ -86,7 +86,9 @@
         
             }
         
        -    private PhaseId phaseId = PhaseId.ANY_PHASE;
        +    private int phaseOrdinal = PhaseId.ANY_PHASE.getOrdinal();
        +
        +    private transient PhaseId phaseId = PhaseId.VALUES.get(phaseOrdinal);
         
             /**
              * <p>Return the identifier of the request processing phase during
        @@ -112,6 +114,7 @@
         	    throw new IllegalArgumentException();
         	}
         	this.phaseId = phaseId;
        +	this.phaseOrdinal = phaseId.getOrdinal();
             }
         
        
        
        Show
        Hanspeter Duennenberger added a comment - Would below change affect signature as well? As workaround this would use the PhaseId ordinal as serialized value in FacesEvent: Index: jsf-api/src/main/java/javax/faces/event/FacesEvent.java =================================================================== --- jsf-api/src/main/java/javax/faces/event/FacesEvent.java (revision 13233) +++ jsf-api/src/main/java/javax/faces/event/FacesEvent.java (working copy) @@ -86,7 +86,9 @@ } - private PhaseId phaseId = PhaseId.ANY_PHASE; + private int phaseOrdinal = PhaseId.ANY_PHASE.getOrdinal(); + + private transient PhaseId phaseId = PhaseId.VALUES.get(phaseOrdinal); /** * <p>Return the identifier of the request processing phase during @@ -112,6 +114,7 @@ throw new IllegalArgumentException(); } this .phaseId = phaseId; + this .phaseOrdinal = phaseId.getOrdinal(); }
        Hide
        Ed Burns added a comment -

        Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

        Show
        Ed Burns added a comment - Set priority to baseline ahead of JSF 2.3 triage. Priorities will be assigned accurately after this exercise.

          People

          • Assignee:
            Unassigned
            Reporter:
            darkarena
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated: