I have an exception when I try to load the TerrainGrid.j3o

I have an exception when I try to load the TerrainGrid.j3o from test data asset.

The exception:

WARNING 17:04:04:146 EditorAreaComponent: IllegalArgumentException : null : stack trace:
java.util.concurrent.ConcurrentLinkedQueue.addAll(ConcurrentLinkedQueue.java:526)
com.jme3.scene.control.UpdateControl.jmeClone(UpdateControl.java:107)
com.jme3.util.clone.Cloner.clone(Cloner.java:249)
com.jme3.util.clone.Cloner.clone(Cloner.java:160)
com.jme3.util.clone.ListCloneFunction.cloneFields(ListCloneFunction.java:66)
com.jme3.util.clone.ListCloneFunction.cloneFields(ListCloneFunction.java:43)
com.jme3.util.clone.Cloner.clone(Cloner.java:228)
com.jme3.util.clone.Cloner.clone(Cloner.java:160)
com.jme3.scene.Spatial.cloneFields(Spatial.java:1505)
com.jme3.scene.Node.cloneFields(Node.java:723)
com.jme3.terrain.geomipmap.TerrainQuad.cloneFields(TerrainQuad.java:1801)
com.jme3.util.clone.Cloner.clone(Cloner.java:255)
com.jme3.util.clone.Cloner.clone(Cloner.java:160)
com.jme3.scene.Spatial.clone(Spatial.java:1360)
com.jme3.scene.Node.clone(Node.java:682)
com.jme3.terrain.geomipmap.TerrainQuad.clone(TerrainQuad.java:1768)
com.jme3.terrain.geomipmap.TerrainQuad.clone(TerrainQuad.java:1763)
com.jme3.terrain.geomipmap.TerrainQuad.clone(TerrainQuad.java:109)
com.jme3.asset.CloneableAssetProcessor.createClone(CloneableAssetProcessor.java:48)
com.jme3.asset.DesktopAssetManager.registerAndCloneSmartAsset(DesktopAssetManager.java:317)
com.jme3.asset.DesktopAssetManager.loadAsset(DesktopAssetManager.java:379)

The method of the com.jme3.scene.control.UpdateControl:

 @Override
    public Object jmeClone() {
        UpdateControl clone = (UpdateControl)super.jmeClone();
        
        // This is kind of questionable since the tasks aren't cloned and have
        // no reference to the new spatial or anything.  They'll get run again
        // but it's not clear to me why that would be desired.  I'm doing it
        // because the old cloneForSpatial() code does.  FIXME?   -pspeed
        clone.taskQueue.addAll(taskQueue);
        return clone;
    }

What is null?

This exception was created from here:

Yeah. That makes complete sense. Throw an exception if null or the collection is the same as the parent. It means whatever you are adding to the collection is null, unless you are adding the collection to itself?

Presumably the taskQue object is null.

EDIT: Looking at that code - it does add itself to the collection. That can’t be right.

The issue is that UpdateControl is not cloning the task queue. It’s trying to add the original’s contents to the clone… that’s what addAll() does.

The old cloning didn’t actually create a clone.

Personally, I fail to see the reason why the tasks are cloned and not deep cloned. But either way, the list should be cloned. So… probably shouldn’t be final either.