# HG changeset patch
# User Adrián Romero <adrianromero@openbravo.com>
# Date 1531312233 -7200
#      Wed Jul 11 14:30:33 2018 +0200
# Node ID 5f8ee210ef8859bcf7b11feb4774b28b1fc01f4c
# Parent  3a6b1b112d8c7663c15aaca3a5f5df330511a370
Fixes issue 38928: No need to load the configuration file from disk to get the property *printers.virtualizeports*

diff --git a/project/src/com/openbravo/pos/printer/escpos/PrinterWritterFile.java b/project/src/com/openbravo/pos/printer/escpos/PrinterWritterFile.java
--- a/project/src/com/openbravo/pos/printer/escpos/PrinterWritterFile.java
+++ b/project/src/com/openbravo/pos/printer/escpos/PrinterWritterFile.java
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2012-2014 Openbravo S.L.U.
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -13,26 +13,21 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
-import com.openbravo.poshw.AppConfig;
-
 public class PrinterWritterFile extends PrinterWritter {
     
     private static final Logger logger = Logger.getLogger(PrinterWritterFile.class.getName());
 
     private static final int BUFFER_SIZE = 2048;
 
-    private final AppConfig config;
-
     private final String m_sFilePrinter;
+    private final boolean closeConnection;
 
     private OutputStream m_out;
 
-    public PrinterWritterFile(String sFilePrinter) {
+    public PrinterWritterFile(String sFilePrinter, boolean closeConnection) {
         m_sFilePrinter = sFilePrinter;
+        this.closeConnection = closeConnection;
         m_out = null;
-        String[] args = new String[0];
-        config = new AppConfig(args);
-        config.load();
     }
 
     @Override
@@ -89,7 +84,6 @@
         try {
             if (m_out != null) {
                 m_out.flush();
-                boolean closeConnection = config.getProperty("printers.virtualizeports").equals("true") ? false : true;
                 if (closeConnection) {
                     m_out.close();
                     m_out = null;
diff --git a/project/src/com/openbravo/pos/service/HardwareConfigInst.java b/project/src/com/openbravo/pos/service/HardwareConfigInst.java
--- a/project/src/com/openbravo/pos/service/HardwareConfigInst.java
+++ b/project/src/com/openbravo/pos/service/HardwareConfigInst.java
@@ -1,6 +1,6 @@
 /*
  ************************************************************************************
- * Copyright (C) 2012-2014 Openbravo S.L.U.
+ * Copyright (C) 2012-2018 Openbravo S.L.U.
  * Licensed under the Openbravo Commercial License version 1.0
  * You may obtain a copy of the License at http://www.openbravo.com/legal/obcl.html
  * or in the legal folder of this module distribution.
@@ -76,7 +76,7 @@
             parseInt(p.nextToken(','), SerialPort.FLOWCONTROL_NONE));
         m_apool.put(skey, pw);
       } else if ("file".equals(param1)) {
-        pw = new PrinterWritterFile(param2);
+        pw = new PrinterWritterFile(param2, !"true".equals(config.getProperty("printers.virtualizeports")));
         m_apool.put(skey, pw);
       } else if ("usb".equals(param1)) {
         pw = new PrinterWritterUSB(USBDeviceList.getPrinterUSBID(devicetype, param2));
