镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Fix NET-200: Treat Unix block and character devices as FTPFile.UNKNOWN_TYPE - #420

Open
Inf1mum wants to merge 1 commit into
apache:masterfrom
Inf1mum:fix/NET-200-device-type
Open

Inf1mum wants to merge 1 commit into
apache:masterfrom
Inf1mum:fix/NET-200-device-type

Conversation

@Inf1mum

@Inf1mum Inf1mum commented Nov 6, 2026

Copy link
Copy Markdown

Overview

NET-200: UnixFTPEntryParser maps listing entries whose type character is b (block device) or c (character device) to FTPFile.FILE_TYPE, so FTPFile#isFile() reports device nodes as regular files. The code carries a // TODO change this if DEVICE_TYPE implemented note, and the JIRA thread agrees these entries should not be files.

Changes

  • UnixFTPEntryParser.parseFTPEntry(): b and c entries now map to FTPFile.UNKNOWN_TYPE instead of FTPFile.FILE_TYPE. As before, the hard-link count is not parsed for device entries (isDevice flag kept), and name/permissions/timestamp parsing is unchanged.
  • src/changes/changes.xml: added a fix action for 3.13.1.

Tests

  • UnixFTPEntryParserTest#testNET200BlockAndCharacterDevicesAreNotFiles (new): block and character device entries parse to FTPFile.UNKNOWN_TYPE, are not isFile()/isDirectory(), are isUnknown(), keep a hard-link count of 0, and still carry a parsed timestamp.
  • UnixFTPEntryParserTest#doAdditionalGoodTests: the existing b/c device samples now assert UNKNOWN_TYPE (previously they fell through to the FILE_TYPE assertion next to the same TODO).

mvn test -Dtest=UnixFTPEntryParserTest passes (24/24), and the full FTP parser suite (DefaultFTPFileEntryParserFactoryTest, EnterpriseUnixFTPEntryParserTest, FTPConfigEntryParserTest, FTPTimestampParserImplTest, MLSxEntryParserTest, MVSFTPEntryParserTest, MacOsPeterFTPEntryParserTest, NTFTPEntryParserTest, NetwareFTPEntryParserTest, OS2FTPEntryParserTest, OS400FTPEntryParserAdditionalTest, OS400FTPEntryParserTest, UnixFTPEntryParserTest, VMSFTPEntryParserTest) passes (134 tests, 0 failures).

Notes

  • Behavior change: consumers filtering FTPClient.listFiles() results with isFile() will no longer pick up device nodes; that is the requested fix for NET-200.
  • No new API; FTPFile constants are unchanged.

Thanks for considering this contribution!

UnixFTPEntryParser mapped 'b' (block device) and 'c' (character device)
listing entries to FTPFile.FILE_TYPE, so FTPFile#isFile() reported
devices as regular files. They now map to FTPFile.UNKNOWN_TYPE, as
agreed on the JIRA issue; the hard-link count is still not parsed for
devices. A dedicated regression test covers block and character device
entries.

Signed-off-by: Inf1mum <vadim.lazuk@mail.ru>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant