HarshSawarkar commented on code in PR #4650:
URL: https://github.com/apache/eventmesh/pull/4650#discussion_r1458902844


##########
eventmesh-connectors/eventmesh-connector-file/src/main/java/org/apache/eventmesh/connector/file/source/connector/FileSourceConnector.java:
##########
@@ -45,20 +56,24 @@ public Class<? extends Config> configClass() {
     public void init(Config config) throws Exception {
         // init config for hdfs source connector
         this.sourceConfig = (FileSourceConfig) config;
-
+        this.filePath = ((FileSourceConfig) 
config).getConnectorConfig().getFilePath();
+        this.fileName = getFileName(filePath);
     }
 
     @Override
     public void init(ConnectorContext connectorContext) throws Exception {
         SourceConnectorContext sourceConnectorContext = 
(SourceConnectorContext) connectorContext;
         this.sourceConfig = (FileSourceConfig) 
sourceConnectorContext.getSourceConfig();
-        this.offsetStorageReader = 
sourceConnectorContext.getOffsetStorageReader();
-
     }
 
     @Override
     public void start() throws Exception {
-
+        if (fileName == null || fileName.isEmpty() || filePath == null || 
filePath.isEmpty()) {
+            this.bufferedReader = new BufferedReader(new 
InputStreamReader(System.in, StandardCharsets.UTF_8));
+        } else {
+            this.bufferedReader = new BufferedReader(new 
InputStreamReader(Files.newInputStream(
+                Paths.get(filePath, fileName)), StandardCharsets.UTF_8), 
BUFFER_SIZE);

Review Comment:
   Updated.Also I have tested the File Source Connector for **_start(), 
stop()_** and **_poll()_** method, locally, and it's running fine.I have 
attached the Ss of the tests I ran on this class below.  
   
![image](https://github.com/apache/eventmesh/assets/96522794/48879a11-8f69-44a9-8f12-74715002d110)
   
![image](https://github.com/apache/eventmesh/assets/96522794/15918ada-ab67-4167-a9db-86ffe4fd772a)
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to