@@ -134,7 +134,7 @@ public static String getJson(ConfiguracoesNfe config, Map<String, String> queryP
134134 try {
135135 HttpClient httpClient = createHttpClient (config , certificado , url );
136136 if (httpClient != null ) {
137- return executeRequestWithHttpClient (httpClient , url );
137+ return executeRequestWithHttpClient (httpClient , url , certificado );
138138 }
139139 } catch (CertificadoException e ) {
140140 log .warning ("[ConsultaTributacao] Falha ao criar HttpClient, tentando fallback: " + e .getMessage ());
@@ -506,15 +506,17 @@ private static HttpClient createHttpClient(ConfiguracoesNfe config, Certificado
506506 }
507507 }
508508
509- private static String executeRequestWithHttpClient (HttpClient httpClient , String url ) throws IOException {
509+ private static String executeRequestWithHttpClient (HttpClient httpClient , String url , Certificado certificado ) throws IOException {
510510 String uri = url ;
511- if (httpClient .getHostConfiguration ().getProtocol () != null ) {
512- try {
513- URL u = new URL (url );
514- httpClient .getHostConfiguration ().setHost (u .getHost (), u .getPort (), httpClient .getHostConfiguration ().getProtocol ());
515- uri = u .getFile ();
516- } catch (Exception e ) {
517- log .warning ("[ConsultaTributacao] Erro ao processar URL para modo multithreading: " + e .getMessage ());
511+ if (certificado .isModoMultithreading ()) {
512+ if (httpClient .getHostConfiguration ().getProtocol () != null ) {
513+ try {
514+ URL u = new URL (url );
515+ httpClient .getHostConfiguration ().setHost (u .getHost (), u .getPort (), httpClient .getHostConfiguration ().getProtocol ());
516+ uri = u .getFile ();
517+ } catch (Exception e ) {
518+ log .warning ("[ConsultaTributacao] Erro ao processar URL para modo multithreading: " + e .getMessage ());
519+ }
518520 }
519521 }
520522
0 commit comments