jeudi 5 mars 2015

Canot call set method on a object that's proxied with Cglib2AopProxy

The following code works fine from a unit test where I build up the test fixture in code. It also works fine if I create a unit test where I define the necessary beans in a spring config xml file. It doesn't work however when I deploy the code and context file to a JEE container.



private Map<Process, QuicCsvUpdater> updateChains = new Hashtable<Process, QuicCsvUpdater>();

public QuicCsvUpdaterChains() {}

public QuicCsvUpdaterChains(Map<Process, List<QuicCsvUpdater>> updaters) {

Set<Entry<Process, List<QuicCsvUpdater>>> entrySet = updaters.entrySet();

for(Entry<Process, List<QuicCsvUpdater>> entry : entrySet) {
updateChains.put(entry.getKey(), join(new ArrayList<QuicCsvUpdater>(entry.getValue())));
}
}


private QuicCsvUpdater join(List<QuicCsvUpdater> updaters) {

if(updaters.size() == 1) {
return updaters.remove(0);
}

QuicCsvUpdater updater = updaters.remove(0);
QuicCsvUpdater next = join(updaters);
updater.setNextInChain(next);
return updater;
}


The call to updater.setNextInChain(next) never actually sets next on the updater. From what I can see in the debugger stepping in at the line updater.setNextInChain(next), in Cglib2AopProxy the call to set takes place on the target but the proxy is never updated.


Why would it be that in Cglib2AopProxy the target is updated but the proxy is never updated to reflect the change?


Aucun commentaire:

Enregistrer un commentaire