[ 
https://issues.apache.org/jira/browse/THRIFT-2582?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ahmed Ali-Eldin updated THRIFT-2582:
------------------------------------

    Environment:     (was: 
)

> "FileTransport error" exception is raised when trying to use Java's 
> TFileTransport 
> -----------------------------------------------------------------------------------
>
>                 Key: THRIFT-2582
>                 URL: https://issues.apache.org/jira/browse/THRIFT-2582
>             Project: Thrift
>          Issue Type: Bug
>          Components: Java - Library
>    Affects Versions: 0.9.1
>            Reporter: Ahmed Ali-Eldin
>
> I am trying to wrap a Java class to be called from Python using thrift's 
> TFileTransport. I tried using two protocols TJSON and TBinary but I keep 
> getting an exception
>     
>     org.apache.thrift.transport.TTransportException: FileTransport error: bad 
> event size
>       at 
> org.apache.thrift.transport.TFileTransport.readEvent(TFileTransport.java:327)
>       at 
> org.apache.thrift.transport.TFileTransport.read(TFileTransport.java:468)
>       at 
> org.apache.thrift.transport.TFileTransport.readAll(TFileTransport.java:439)
>       at 
> org.apache.thrift.protocol.TJSONProtocol$LookaheadReader.read(TJSONProtocol.java:263)
>       at 
> org.apache.thrift.protocol.TJSONProtocol.readJSONSyntaxChar(TJSONProtocol.java:320)
>       at 
> org.apache.thrift.protocol.TJSONProtocol.readJSONArrayStart(TJSONProtocol.java:784)
>       at 
> org.apache.thrift.protocol.TJSONProtocol.readMessageBegin(TJSONProtocol.java:795)
>       at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
>       at 
> org.apache.thrift.transport.TFileProcessor.processUntil(TFileProcessor.java:69)
>       at 
> org.apache.thrift.transport.TFileProcessor.processChunk(TFileProcessor.java:102)
>       at 
> org.apache.thrift.transport.TFileProcessor.processChunk(TFileProcessor.java:111)
>       at 
> org.apache.thrift.transport.TFileProcessor.processChunk(TFileProcessor.java:118)
>       at 
> com.netflix.suro.client.SendToPyServer.startThriftServer(SendToPyServer.java:51)
>       at com.netflix.suro.client.SendToPyServer.main(SendToPyServer.java:67)
> This is how my Python client looks:
>      def __init__(self):
>             self.outFile=open("../../ThriftFile.in","a")
>             self.transport = TTransport.TFileObjectTransport(self.outFile)
>             self.protocol = TJSONProtocol.TJSONProtocol(self.transport)
>             self.client = sendPyInterface.Client(self.protocol)
>             self.transport.open()
>         
>         def send(self,routingKey, message):
>             self.client.send_send(routingKey, message)
>                   
>         def configClient(self,configurationDict):       
>              self.client.send_ClientConfig(configurationDict)   
>             
>     if __name__ == "__main__":
>         SuroClient=SuroPyClient()
>         
> configurationDict={"ClientConfig.LB_TYPE":"static","ClientConfig.LB_SERVER":"localhost:7101"}
>         SuroClient.configClient(configurationDict)
>         SuroClient.send("routingKey", "testMessage")
> and this is my server (or rather one version I have tried):
>     public static void startThriftServer(SendPyInterface.Processor processor) 
> {
>                   try {
>                       File input = new 
> File("src/main/java/com/netflix/suro/client/ThriftFile.in");
>                       if(!input.exists()){
>                           input.createNewFile();
>                       }
>     
>                       File output = new 
> File("src/main/java/com/netflix/suro/client/ThriftFile.out");
>                       if(!output.exists()){
>                           output.createNewFile();
>                       }
>                       
>                       TFileTransport inputFileTransport = new 
> TFileTransport(input.getAbsolutePath(), true);
>                       TFileTransport outputFileTransport = new 
> TFileTransport(output.getAbsolutePath(), false);
>    
>     
>                       inputFileTransport.open();
>                       outputFileTransport.open();
>                       
>                       
> inputFileTransport.setTailPolicy(tailPolicy.WAIT_FOREVER);
>                       TFileProcessor fProcessor = 
>                               new TFileProcessor(processor, new 
> TJSONProtocol.Factory(), inputFileTransport, outputFileTransport);
>                       try {
>                               fProcessor.processChunk();
>                               } catch (TTransportException e) {
>                                       e.printStackTrace();
>                               }
>                               
>     
>                       System.out.println("File Thrift service started ...");
>                   } catch (Exception e) {
>                       e.printStackTrace();
>                   }
> I have been able to read the JSON file using Python, but not Java. JenG 
> suggested on StackOverFlow that this is a bug.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to