Lucas_Cavalcanti 13 de out. de 2011
Bom, o FileDownload delega pro InputStreamDownload que usa o ByteStreams.copy, que teoricamente fecha o stream… não deveria dar problema com isso…
será que não tem outro lugar travando o arquivo?
Romulinho 13 de out. de 2011
Cara, olhando o fonte do ByteStreams.copy não vi o stream sendo fechado. A versão do Guava que tenho é r07, que já vem como dependência do VRaptor.
Apenas pra conhecimento, o código que vejo é:
public static long copy ( InputStream from , OutputStream to ) throws IOException {
byte [] buf = new byte [ BUF_SIZE ] ;
long total = 0 ;
while ( true ) {
int r = from . read ( buf );
if ( r == - 1 ) {
break ;
}
to . write ( buf , 0 , r );
total += r ;
}
return total ;
}
Nem o “from” nem o “to” são fechados.
Lucas_Cavalcanti 13 de out. de 2011
=(
por favor abra uma issue no VRaptor pra isso:
se quiser corrigir e mandar um pull request tb =)
por enquanto na sua aplicação vc pode copiar essa classe:
/***
* Copyright (c) 2009 Caelum - www.caelum.com.br/opensource
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package br.com.caelum.vraptor.interceptor.download ;
import java.io.File ;
This file has been truncated. show original
e fechar o stream no final.
Romulinho 13 de out. de 2011
Blz Lucas! Valeu pela atenção! Vou abrir a issue sim, só não vou garantir o pull request, mas vou fazer o possível!
Lucas_Cavalcanti 13 de out. de 2011
Romulinho 14 de out. de 2011
E aí Lucas, Issue cadastrada e Pull Request enviado.
Valeu!
Lucas_Cavalcanti 14 de out. de 2011
garcia-jj 7 de nov. de 2011
Ví que o pull-request ainda está aberto, e fiz uns testes com esse teu pull request e funcionou tudo bem.
Não consegui testar esse lance de lock de arquivo porque o Linux não faz esse lock que nem no Windows.
Abraços