#vulnerable code 
                                public static void main(final String[] args) throws Exception {
        if (args.length < 1 || args.length > 2) {
            System.err.println("Incorrect number of arguments: " + args.length);
            printUsage();
            return;
        }
        final int port = Integer.parseInt(args[0]);
        if (port <= 0 || port >= MAX_PORT) {
            System.err.println("Invalid port number:" + port);
            printUsage();
            return;
        }
        if (args.length == 2 && args[1].length() > 0) {
            ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(args[1]));
        }
        final UdpSocketServer<ObjectInputStream> socketServer = UdpSocketServer.createSerializedSocketServer(port);
        final Thread server = new Log4jThread(socketServer);
        server.start();
        final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        while (true) {
            final String line = reader.readLine();
            if (line == null || line.equalsIgnoreCase("Quit") || line.equalsIgnoreCase("Stop")
                    || line.equalsIgnoreCase("Exit")) {
                socketServer.shutdown();
                server.join();
                break;
            }
        }
    } 
                            #location 22 
                            #vulnerability type RESOURCE_LEAK
#fixed code
                                public static void main(final String[] args) throws Exception {
        final CommandLineArguments cla = parseCommandLine(args, UdpSocketServer.class, new CommandLineArguments());
        if (cla.isHelp()) {
            return;
        }
        if (cla.getConfigLocation() != null) {
            ConfigurationFactory.setConfigurationFactory(new ServerConfigurationFactory(cla.getConfigLocation()));
        }
        final UdpSocketServer<ObjectInputStream> socketServer = UdpSocketServer
                .createSerializedSocketServer(cla.getPort());
        final Thread serverThread = new Log4jThread(socketServer);
        serverThread.start();
        if (cla.isInteractive()) {
            final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
            while (true) {
                final String line = reader.readLine();
                if (line == null || line.equalsIgnoreCase("Quit") || line.equalsIgnoreCase("Stop")
                        || line.equalsIgnoreCase("Exit")) {
                    socketServer.shutdown();
                    serverThread.join();
                    break;
                }
            }
        }
    }