Je rencontre des problèmes pour exécuter correctement un bloc de code. Je ne suis pas totalement sûr de CE QUE fait ce code (j'essaie de faire fonctionner correctement un plugin obsolète avec notre serveur), je sais juste qu'il s'exécute toutes les 20 minutes et génère une erreur. Voici la section du code où le problème se produit :
public class DynamicThread extends Thread {
private LocalShops plugin = null;
public DynamicThread(ThreadGroup tgroup, String tname, LocalShops plugin) {
super(tgroup, tname);
this.plugin = plugin;
}
public void run() {
Map> itemStockMap = Collections.synchronizedMap(new HashMap>());
//Dump all the shop stock data into the map.
for ( Shop shop : plugin.getShopManager().getAllShops() ) {
for ( InventoryItem item : shop.getItems() ) {
if (itemStockMap.containsKey(item.getInfo()))
itemStockMap.get(item.getInfo()).add(item.getStock()); //Where error happens
else
itemStockMap.put(item.getInfo(), Arrays.asList(item.getStock()));
}
}
for(ItemInfo item : itemStockMap.keySet()) {
List stockList = GenericFunctions.limitOutliers(itemStockMap.get(item));
//remove the map before re-adding it
if (DynamicManager.getPriceAdjMap().containsKey(item))
DynamicManager.getPriceAdjMap().remove(item);
//Get the overall stock change for a given item and then calculate the adjustment given the volatility
int deltaStock = GenericFunctions.getSum(stockList) - Config.getGlobalBaseStock();
DynamicManager.getPriceAdjMap().put(item, GenericFunctions.getAdjustment(Config.getGlobalVolatility(), deltaStock));
}
Bukkit.getServer().getScheduler().callSyncMethod(plugin, plugin.getShopManager().updateSigns());
}
}
L'erreur se produit à partir de la ligne 42, qui est :
itemStockMap.get(item.getInfo()).add(item.getStock());
L'erreur se produit toutes les 20 minutes deux fois avec 2 secondes d'intervalle.
2012-02-16 16:53:25 [INFO] Lancer le fil dynamique
2012-02-16 16:53:25 [GRAVE] Exception dans le fil "dynamique"
2012-02-16 16:53:25 [GRAVE] java.lang.UnsupportedOperationException
2012-02-16 16:53:25 [GRAVE] à java.util.AbstractList.add(AbstractList.java:131)
2012-02-16 16:53:25 [GRAVE] à java.util.AbstractList.add(AbstractList.java:91)
2012-02-16 16:53:25 [GRAVE] à com.milkbukkit.localshops.threads.DynamicThread.run(DynamicThread.java:42)
2012-02-16 16:53:27 [INFO] Lancer le fil dynamique
2012-02-16 16:53:27 [GRAVE] Exception dans le fil "dynamique"
2012-02-16 16:53:27 [GRAVE] java.lang.UnsupportedOperationException
2012-02-16 16:53:27 [GRAVE] à java.util.AbstractList.add(AbstractList.java:131)
2012-02-16 16:53:27 [GRAVE] à java.util.AbstractList.add(AbstractList.java:91)
2012-02-16 16:53:27 [GRAVE] à com.milkbukkit.localshops.threads.DynamicThread.run(DynamicThread.java:42)