1
0
mirror of https://github.com/Rogiel/l2jserver2 synced 2025-12-05 23:22:47 +00:00

Fixes issues found by findbugs

This commit is contained in:
2011-12-29 13:27:55 -02:00
parent 92ebaacf67
commit 1f2b700311
10 changed files with 28 additions and 35 deletions

View File

@@ -63,8 +63,10 @@ public class CSVUtils {
public static <R> List<R> parseCSV(BufferedReader reader, public static <R> List<R> parseCSV(BufferedReader reader,
CSVProcessor<R> processor) throws IOException { CSVProcessor<R> processor) throws IOException {
final List<R> results = CollectionFactory.newList(); final List<R> results = CollectionFactory.newList();
final String header[] = reader.readLine().split(","); String line = reader.readLine();
String line; if (line == null)
return results;
final String header[] = line.split(",");
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
results.add(processor.process(header, line.split(","))); results.add(processor.process(header, line.split(",")));
} }

View File

@@ -48,9 +48,9 @@ public class PluginLoader implements Loader, Unloader {
* @return list of Template classes to load/unload * @return list of Template classes to load/unload
*/ */
@SuppressWarnings({ "unchecked", "unused" }) @SuppressWarnings({ "unchecked", "unused" })
private static Set<Class<? extends Template<?>>> getSuitableClasses( private static Set<Class<? extends Template>> getSuitableClasses(
Class<?>[] classes) { Class<?>[] classes) {
final Set<Class<? extends Template<?>>> suitable = CollectionFactory final Set<Class<? extends Template>> suitable = CollectionFactory
.newSet(); .newSet();
for (Class<?> clazz : classes) { for (Class<?> clazz : classes) {
if (!ClassUtils.isSubclass(clazz, Template.class)) if (!ClassUtils.isSubclass(clazz, Template.class))
@@ -63,7 +63,7 @@ public class PluginLoader implements Loader, Unloader {
if (clazz.isAnnotationPresent(DisabledPlugin.class)) if (clazz.isAnnotationPresent(DisabledPlugin.class))
continue; continue;
suitable.add((Class<? extends Template<?>>) clazz); suitable.add((Class<? extends Template>) clazz);
} }
return suitable; return suitable;

View File

@@ -57,7 +57,7 @@ public class L2JGameServerMain {
/** /**
* List of start services * List of start services
*/ */
public static final Class<?>[][] SERVICES = { private static final Class<?>[][] SERVICES = {
// core services // core services
{ CacheService.class, ConfigurationService.class, { CacheService.class, ConfigurationService.class,
DatabaseService.class, WorldIDService.class, DatabaseService.class, WorldIDService.class,

View File

@@ -45,7 +45,7 @@ public class CM_REQUEST_CHAR_TEMPLATE extends AbstractClientPacket {
/** /**
* List of {@link CharacterClass} templates sent to the client * List of {@link CharacterClass} templates sent to the client
*/ */
protected static final CharacterClass[] TEMPLATE_CLASSES = { private static final CharacterClass[] TEMPLATE_CLASSES = {
CharacterClass.HUMAN_FIGHTER, CharacterClass.HUMAN_MYSTIC, CharacterClass.HUMAN_FIGHTER, CharacterClass.HUMAN_MYSTIC,
CharacterClass.ELVEN_FIGHTER, CharacterClass.ELVEN_MYSTIC, CharacterClass.ELVEN_FIGHTER, CharacterClass.ELVEN_MYSTIC,
CharacterClass.DARK_FIGHTER, CharacterClass.DARK_MYSTIC, CharacterClass.DARK_FIGHTER, CharacterClass.DARK_MYSTIC,

View File

@@ -37,7 +37,6 @@ import com.l2jserver.service.ServiceStartException;
import com.l2jserver.service.ServiceStopException; import com.l2jserver.service.ServiceStopException;
import com.l2jserver.service.database.DataAccessObject; import com.l2jserver.service.database.DataAccessObject;
import com.l2jserver.service.game.region.Region; import com.l2jserver.service.game.region.Region;
import com.l2jserver.service.game.region.RegionService;
import com.l2jserver.util.factory.CollectionFactory; import com.l2jserver.util.factory.CollectionFactory;
/** /**
@@ -56,10 +55,10 @@ public class SimpleChatService extends AbstractService implements ChatService {
* The {@link ChatLoggingService} implementation * The {@link ChatLoggingService} implementation
*/ */
private final ChatLoggingService chatLoggingService; private final ChatLoggingService chatLoggingService;
/** // /**
* The {@link RegionService} // * The {@link RegionService}
*/ // */
private final RegionService regionService; // private final RegionService regionService;
/** /**
* The {@link L2Character} DAO * The {@link L2Character} DAO
*/ */
@@ -90,6 +89,7 @@ public class SimpleChatService extends AbstractService implements ChatService {
/** /**
* The list of regional chat channels * The list of regional chat channels
*/ */
@SuppressWarnings("unused")
private Map<Region, RegionChatChannelImpl> regionChannels; private Map<Region, RegionChatChannelImpl> regionChannels;
/** /**
@@ -105,7 +105,6 @@ public class SimpleChatService extends AbstractService implements ChatService {
CharacterDAO charDao) { CharacterDAO charDao) {
this.chatLoggingService = chatLogService; this.chatLoggingService = chatLogService;
// this.regionService = regionService; // this.regionService = regionService;
this.regionService = null;
this.charDao = charDao; this.charDao = charDao;
} }
@@ -178,13 +177,14 @@ public class SimpleChatService extends AbstractService implements ChatService {
@Override @Override
public PublicChatChannel getRegionChannel(L2Character character) { public PublicChatChannel getRegionChannel(L2Character character) {
Preconditions.checkNotNull(character, "character"); Preconditions.checkNotNull(character, "character");
final Region region = regionService.getRegion(character); // final Region region = regionService.getRegion(character);
RegionChatChannelImpl channel = regionChannels.get(region); // RegionChatChannelImpl channel = regionChannels.get(region);
if (channel == null) { // if (channel == null) {
channel = new RegionChatChannelImpl(region); // channel = new RegionChatChannelImpl(region);
regionChannels.put(region, channel); // regionChannels.put(region, channel);
} // }
return channel; // return channel;
return null;
} }
@Override @Override
@@ -468,6 +468,7 @@ public class SimpleChatService extends AbstractService implements ChatService {
* @param region * @param region
* the region represented in this channel * the region represented in this channel
*/ */
@SuppressWarnings("unused")
public RegionChatChannelImpl(Region region) { public RegionChatChannelImpl(Region region) {
Preconditions.checkNotNull(region, "region"); Preconditions.checkNotNull(region, "region");
this.region = region; this.region = region;

View File

@@ -174,14 +174,4 @@ public interface ScriptContext {
*/ */
@Override @Override
int hashCode(); int hashCode();
/**
* This method overrides finalization to ensure that active script context
* will not be collected by GC. If such situation happens -
* {@link #shutdown()} is called to ensure that resources were released.
*
* @throws Throwable
* if something goes wrong during finalization
*/
void finalize() throws Throwable;
} }

View File

@@ -340,7 +340,7 @@ public class ScriptContextImpl implements ScriptContext {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public void finalize() throws Throwable { protected void finalize() throws Throwable {
if (compilationResult != null) { if (compilationResult != null) {
log.error("Finalization of initialized ScriptContext. Forcing context shutdown."); log.error("Finalization of initialized ScriptContext. Forcing context shutdown.");
shutdown(); shutdown();

View File

@@ -284,7 +284,7 @@ public class WorldEventDispatcherServiceImpl extends
return false; return false;
if (complete) if (complete)
return false; return false;
return cancel(mayInterruptIfRunning); return super.cancel(mayInterruptIfRunning);
} }
@Override @Override

View File

@@ -51,12 +51,12 @@ public class ItemTemplateIDAdapter extends XmlAdapter<Integer, ItemTemplateID> {
@Override @Override
public ItemTemplateID unmarshal(Integer v) throws Exception { public ItemTemplateID unmarshal(Integer v) throws Exception {
if (v == null)
return null;
if (v == 0) if (v == 0)
return null; return null;
if (provider == null) if (provider == null)
return new ItemTemplateID(v, null); return new ItemTemplateID(v, null);
if (v == null)
v = 57; // FIXME create constant holding important item ids
return provider.resolveID(v); return provider.resolveID(v);
} }