{"record":{"id":"a7effe304bc0db34","repo":"pentaho/pentaho-kettle","slug":"setting-a-directory-on-a-database-connection-is-not-a7effe","errorCode":null,"errorMessage":"Setting a directory on a database connection is not supported","messagePattern":"Setting a directory on a database connection is not supported","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/cluster/SlaveServer.java","lineNumber":1270,"sourceCode":"      lock.readLock().unlock();\n    }\n  }\n\n  public void setObjectId( ObjectId id ) {\n    lock.writeLock().lock();\n    this.id = id;\n    lock.writeLock().unlock();\n  }\n\n  /**\n   * Not used in this case, simply return root /\n   */\n  public RepositoryDirectoryInterface getRepositoryDirectory() {\n    return new RepositoryDirectory();\n  }\n\n  public void setRepositoryDirectory( RepositoryDirectoryInterface repositoryDirectory ) {\n    throw new RuntimeException( \"Setting a directory on a database connection is not supported\" );\n  }\n\n  public RepositoryObjectType getRepositoryElementType() {\n    return REPOSITORY_ELEMENT_TYPE;\n  }\n\n  public ObjectRevision getObjectRevision() {\n    lock.readLock().lock();\n    try {\n      return objectRevision;\n    } finally {\n      lock.readLock().unlock();\n    }\n  }\n\n  public void setObjectRevision( ObjectRevision objectRevision ) {\n    lock.writeLock().lock();\n    this.objectRevision = objectRevision;","sourceCodeStart":1252,"sourceCodeEnd":1288,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/cluster/SlaveServer.java#L1252-L1288","documentation":"SlaveServer implements RepositoryElementInterface, which requires a repository directory attribute, but a slave server is not a repository element — its getRepositoryDirectory always returns a fresh empty RepositoryDirectory. Calling setRepositoryDirectory is therefore a programming error and throws an UnsupportedOperationException-style RuntimeException.","triggerScenarios":"Code that generically handles RepositoryElementInterface objects (e.g. repository import/export or generic save logic) calls setRepositoryDirectory on a SlaveServer instance.","commonSituations":"Generic metadata-processing code that sets directories on all repository elements without checking the element type; migration/import scripts treating slave servers as repo objects.","solutions":["Do not call setRepositoryDirectory on SlaveServer objects","Guard with an instanceof/capability check before assigning a directory","If a directory-like notion is needed for slaves, model it in your own code, not via this API"],"exampleFix":"// before: setting directory unconditionally\nrepositoryElement.setRepositoryDirectory(directory);\n// after: only set for actual repository elements\nif (!(repositoryElement instanceof SlaveServer)) { repositoryElement.setRepositoryDirectory(directory); }","handlingStrategy":"type-guard","validationCode":"// Guard before mutating repository element properties\nif (element instanceof SlaveServer) { return; // skip directory assignment\n}","typeGuard":"boolean supportsDirectory(Object element) { return !(element instanceof SlaveServer); }","tryCatchPattern":"try { element.setRepositoryDirectory(dir); }\ncatch (RuntimeException e) { if (e.getMessage().contains(\"not supported\")) { log.warn(\"Skipped directory set on \" + element.getClass().getSimpleName()); return; } throw e; }","preventionTips":["Never treat SlaveServer as a repository element when iterating RepositoryElementInterface collections","Filter slave servers out of generic import/export logic","Model slave paths outside the repository-element API"],"tags":["unsupported-operation","slave-server","repository"],"backgroundTag":"unsupported-operation","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}