Directory Studio
  1. Directory Studio
  2. DIRSTUDIO-585

Do not modify the current thread's ClassLoader; or reset it afterwards

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.4.0, 1.5.0
    • Fix Version/s: 1.5.3
    • Component/s: studio-ldapbrowser
    • Labels:
      None

      Description

      Hi,

      in BrowserConnectionManager.load
      and in
      Utils.serialize / deserialize
      we recognized that the ClassLoader is modified without conserving / resetting it to the previous one at the end.
      This conflicted with our class loading mechanisms ... streaming from our own class store.

      As a quick fix for testing, we could do for example the following; however, this is not a real solution:

      public static String serialize( Object o )
      {
      String s = null;
      Thread cur_thrd = Thread.currentThread(); //patch reset current class loader
      ClassLoader cur_thrd_cl = cur_thrd.getContextClassLoader();
      try

      { cur_thrd.setContextClassLoader( Utils.class.getClassLoader() ); ByteArrayOutputStream baos = new ByteArrayOutputStream(); XMLEncoder encoder = new XMLEncoder( baos ); encoder.writeObject( o ); encoder.close(); s = LdifUtils.utf8decode( baos.toByteArray() ); }

      finally

      { cur_thrd.setContextClassLoader(cur_thrd_cl); }

      return s;
      }

      => Is there a better way?

      Thanks and regards,
      Karsten

        Activity

        Hide
        Stefan Seelmann added a comment -

        Thanks Karsten for the proposed workaround.

        I think we should get rid of the XMLEncoder at all.

        In Utils it is used to store some preferences and I was to lazy to build our own Object<->XML mapping. I'll add your proposed workaround here.

        In BrowserConnectionManager it is only used for backward compatibility to be able to convert old connections.xml format. I think we use the new file format since 1.0. So the code in this class should never be executed. Let's remove the legacy code with Studio 2.0

        Show
        Stefan Seelmann added a comment - Thanks Karsten for the proposed workaround. I think we should get rid of the XMLEncoder at all. In Utils it is used to store some preferences and I was to lazy to build our own Object<->XML mapping. I'll add your proposed workaround here. In BrowserConnectionManager it is only used for backward compatibility to be able to convert old connections.xml format. I think we use the new file format since 1.0. So the code in this class should never be executed. Let's remove the legacy code with Studio 2.0
        Hide
        Stefan Seelmann added a comment -
        Show
        Stefan Seelmann added a comment - Fixed in trunk: http://svn.apache.org/viewvc?rev=920308&view=rev
        Hide
        Pierre-Arnaud Marcelot added a comment -

        Version 1.5.3 has been released.
        Let's close this issue.

        Show
        Pierre-Arnaud Marcelot added a comment - Version 1.5.3 has been released. Let's close this issue.

          People

          • Assignee:
            Stefan Seelmann
            Reporter:
            Karsten Baensch
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development