<commit_before>
package com.brunocapezzali;

import java.io.IOException;
import java.net.Socket;
import org.json.JSONException;

public class ConnectedDeviceManager extends Thread {
   private static final String TAG = "ConnectedDeviceManager";
   
   private final MainServer mServer;
   private final Device mNewDevice;
   
   public ConnectedDeviceManager(MainServer server, Socket deviceSock) throws IOException {
      mServer = server;
      mNewDevice = new Device(mServer, deviceSock);
   }
      
   private void abortDeviceConnection(String error) {
      Utils.log(TAG, "Aborting device connection. ERROR: "+ error);
      mNewDevice.sockClose();
   }
   
   private boolean authenticateDevice() {
      /* The authentication can be based on:
       * - SSL
       * - WelcomeJSON parameters and custom authentication algorithm
       * - Database check of the device
       */
      return true;
   }
   
   @Override
   public void run() {
      try {
         Utils.log(TAG, "Waiting for the auth json ...");
         try {
            mNewDevice.readWelcomeJSON();
         } catch (JSONException ex) {
            abortDeviceConnection(ex.getMessage());
         } catch (IOException ex) {
            abortDeviceConnection(ex.getMessage());
         }
         
         if ( !authenticateDevice() ) {
            abortDeviceConnection("Unable to authenticate the device");
         }
         
         Utils.log(TAG, "Authentication success!\n"
                 +"Adding the device to daemon's clients list.");
         mServer.addDevice(mNewDevice);
         
      } catch (Exception ex) {
         abortDeviceConnection("Unhandled error: "+ ex.getMessage());
      }
   }
   
}<commit_msg>fixed wrong welcome message bug<commit_after>
package com.brunocapezzali;

import java.io.IOException;
import java.net.Socket;
import org.json.JSONException;

public class ConnectedDeviceManager extends Thread {
   private static final String TAG = "ConnectedDeviceManager";
   
   private final MainServer mServer;
   private final Device mNewDevice;
   
   public ConnectedDeviceManager(MainServer server, Socket deviceSock) throws IOException {
      mServer = server;
      mNewDevice = new Device(mServer, deviceSock);
   }
      
   private void abortDeviceConnection(String error) {
      Utils.log(TAG, "Aborting device connection. ERROR: "+ error);
      mNewDevice.sockClose();
   }
   
   private boolean authenticateDevice() {
      /* The authentication can be based on:
       * - SSL
       * - WelcomeJSON parameters and custom authentication algorithm
       * - Database check of the device
       */
      return true;
   }
   
   @Override
   public void run() {
      try {
         Utils.log(TAG, "Waiting for the welcome json ...");
         try {
            mNewDevice.readWelcomeJSON();
         } catch (JSONException ex) {
            abortDeviceConnection(ex.getMessage());
            return;
         } catch (IOException ex) {
            abortDeviceConnection(ex.getMessage());
            return;
         }
         
         if ( !authenticateDevice() ) {
            abortDeviceConnection("Unable to authenticate the device");
            return;
         }
         
         Utils.log(TAG, "Authentication success!\n"
                 +"Adding the device to daemon's clients list.");
         mServer.addDevice(mNewDevice);
         
      } catch (Exception ex) {
         abortDeviceConnection("Unhandled error: "+ ex.getMessage());
      }
   }
   
}
{'fraction_non_alphanumeric': 0.08935198401370253, 'fraction_numerical': 0.0, 'mean_word_length': 2.2565055762081783, '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': '3954040', 'n_tokens_mistral': 919, 'n_tokens_neox': 901, 'n_words': 247}