Serial stops returning data. java.io.IOException: Device not configured in write

So the far left and far right switch just reverse a motor detection and therefore can be registered to the same pin. The pin detects if one of the two switches closes. Given this, does that circuit work?

As far as the circuit is concerned, yes, it should work. If the switches are normally closed, and open when the device reaches the end, then the pin should go low when either switch is opened.

You'd need to consider debouncing issues anyway.

It seems to me, unless you are very short of pins, you are opening yourself up to extra debouncing grief by doing it this way.

if you just had one switch on the pin, then when you get to the left end, the only way to go next is right. And that would be true,
no matter how many times the switch bounced. Bounce bounce bounce, go right, go right, go right.

With your arrangement, you would hit the left end, and if you had bounces, you would go right, go left, go right, go left, which would
just make the bouncing last forever......