cannot re-use ConstantMap - new test may break applications

Hello VisAD community,

A recent Exception report led to the discovery that VisAD
was not testing for applications re-using ConstantMaps in
multiple addReference() and addReferences() calls. Re-use
of ConstantMaps can lead to mysterious and hard-to-diagnose
problems, so the system must prohibit re-use. I have just
updated the VisAD server with source and class files that
do test for this.

The problem is that there may be applications out there
that have been re-using ConstantMaps and getting away with
it.

The one thing we hate to do is make any system changes that
require people to change their applications, but in this
case we have no choice.

However, we have added a work-around to make it as painless
as possible. If you don't want to have to remove ConstantMap
re-use from your applications, you can instead insert the
following static method call at the start of your application:

  ConstantMap.setAllowMultipleUseKludge(true);

Thanks to Dave Glowacki for suggesting this work-around.

Just to make it clear what ConstantMap re-use looks like and
how to fix it, here is my own violation of the rule from
visad/examples/Test27.java:


    ConstantMap[][] maps = {{new ConstantMap(1.0f, Display.Red),
                             new ConstantMap(1.0f, Display.Green),
                             new ConstantMap(0.0f, Display.Blue),
                             new ConstantMap(5.0f, Display.PointSize)}};
    dpys[0].addReferences(new DirectManipulationRendererJ3D(),
                           new DataReference[] {ref_direct_low}, maps);

    final DataReferenceImpl ref_direct_hi
      new DataReferenceImpl("ref_direct_hi");
    ref_direct_hi.setData(direct_hi);
    dpys[0].addReferences(new DirectManipulationRendererJ3D(),
                           new DataReference[] {ref_direct_hi}, maps);

Note the ConstantMaps in the maps array are used in two
addReferences() calls. The fix was to change this code to:

    ConstantMap[][] maps = {{new ConstantMap(1.0f, Display.Red),
                             new ConstantMap(1.0f, Display.Green),
                             new ConstantMap(0.0f, Display.Blue),
                             new ConstantMap(5.0f, Display.PointSize)}};
    dpys[0].addReferences(new DirectManipulationRendererJ3D(),
                           new DataReference[] {ref_direct_low}, maps);

    final DataReferenceImpl ref_direct_hi
      new DataReferenceImpl("ref_direct_hi");
    ref_direct_hi.setData(direct_hi);
    maps = new ConstantMap[][] {{new ConstantMap(1.0f, Display.Red),
                                 new ConstantMap(1.0f, Display.Green),
                                 new ConstantMap(0.0f, Display.Blue),
                                 new ConstantMap(5.0f, Display.PointSize)}};
    dpys[0].addReferences(new DirectManipulationRendererJ3D(),
                           new DataReference[] {ref_direct_hi}, maps);

Sorry for the inconvenience this causes.

Cheers,
Bill
----------------------------------------------------------
Bill Hibbard, SSEC, 1225 W. Dayton St., Madison, WI  53706
hibbard@xxxxxxxxxxxxxxxxx  608-263-4427  fax: 608-263-6738
http://www.ssec.wisc.edu/~billh/vis.html


  • 2001 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: