<commit_before>package com.inmobi.messaging;

import java.io.IOException;
import java.net.ServerSocket;

public class PortNumberUtil {

  public static int getFreePortNumber(int defaultPortNumber) {
    int port = defaultPortNumber;
    try {
      ServerSocket socket = new ServerSocket(0);
      port = socket.getLocalPort();
    } catch (IOException e) {
      System.out.println("IOException occured while creating socket."
          + " Use a default port number " +  port);<commit_msg>close the socket to make the port number available to others<commit_after>package com.inmobi.messaging;

import java.io.IOException;
import java.net.ServerSocket;

public class PortNumberUtil {

  public static int getFreePortNumber(int defaultPortNumber) {
    int port = defaultPortNumber;
    ServerSocket socket = null;
    try {
      socket = new ServerSocket(0);
      port = socket.getLocalPort();
    } catch (IOException e) {
      System.out.println("IOException occured while creating socket."
          + " Use a default port number " +  port);
    } finally {
      try {
        if (socket != null) {
          socket.close();
        }
      } catch (IOException e) {
        return defaultPortNumber;
      }
{'fraction_non_alphanumeric': 0.08963815789473684, 'fraction_numerical': 0.001644736842105263, 'mean_word_length': 2.9901639344262296, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '261808', 'n_tokens_mistral': 333, 'n_tokens_neox': 328, 'n_words': 98}